~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to src/fs/coss/store_io_coss.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2007-05-13 16:03:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070513160316-2h6kn6h1z0q1fvyo
Tags: 3.0.PRE6-1
* New upstream release
  - Removed patches integrated upsteam:
    + 04-m68k-ftbfs

* debian/rules
  - Enable delay pools (Closes: #410785)
  - Enable cache digests (Closes: #416631)
  - Enable ICAP client
  - Raised Max Filedescriptor limit to 65536

* debian/control
  - Added real package dependency for httpd in squid3-cgi

* debian/patches/02-makefile-defaults
  - Fix default configuration file for cachemgr.cgi (Closes: #416630)

* debian/squid3.postinst
  - Fixed bashish in postinst (Closes: #411797)

* debian/patches/05-helpers-typo
  - Added upstream patch fixing compilation error in src/helpers.cc

* debian/patches/06-mem-obj-reference
  - Added upstream patch fixing a mem_obj reference in src/store.cc

* debian/patches/07-close-icap-connections
  - Added upstream patch fixing icap connection starvation

* debian/squid3.rc
  - Added LSB-compliant description to rc script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: store_io_coss.cc,v 1.29 2006/05/23 00:39:32 wessels Exp $
 
3
 * $Id: store_io_coss.cc,v 1.32 2007/04/30 16:56:16 wessels Exp $
4
4
 *
5
5
 * DEBUG: section 79    Storage Manager COSS Interface
6
6
 * AUTHOR: Eric Stern
80
80
    if (e->swap_file_sz > 0)
81
81
        allocsize = e->swap_file_sz;
82
82
    else
83
 
        allocsize = objectLen(e) + e->mem_obj->swap_hdr_sz;
 
83
        allocsize = e->objectLen() + e->mem_obj->swap_hdr_sz;
84
84
 
85
85
    /* Check if we have overflowed the disk .. */
86
86
    /* max_size is int, so cast to (off_t) *before* bit-shifting */
94
94
        current_membuf->diskend = current_offset;
95
95
        current_membuf->maybeWrite(this);
96
96
        current_offset = 0;     /* wrap back to beginning */
97
 
        debug(79, 2) ("CossSwapDir::allocate: wrap to 0\n");
 
97
        debugs(79, 2, "CossSwapDir::allocate: wrap to 0");
98
98
 
99
99
        newmb = createMemBuf(0, checkf, &coll);
100
100
        current_membuf = newmb;
108
108
        current_membuf->flags.full = 1;
109
109
        current_offset = current_membuf->diskend;
110
110
        current_membuf->maybeWrite(this);
111
 
        debug(79, 2) ("CossSwapDir::allocate: New offset - %ld\n",
112
 
                      (long int) current_offset);
 
111
        debugs(79, 2, "CossSwapDir::allocate: New offset - " << current_offset);
113
112
        newmb = createMemBuf(current_offset, checkf, &coll);
114
113
        current_membuf = newmb;
115
114
    }
126
125
        return storeCossDiskOffsetToFileno(retofs);
127
126
    } else {
128
127
        StoreFScoss::GetInstance().stats.alloc.collisions++;
129
 
        debug(79, 3) ("CossSwapDir::allocate: Collision\n");
 
128
        debugs(79, 3, "CossSwapDir::allocate: Collision");
130
129
        return -1;
131
130
    }
132
131
}
134
133
void
135
134
CossSwapDir::unlink(StoreEntry & e)
136
135
{
137
 
    debug(79, 3) ("storeCossUnlink: offset %d\n", e.swap_filen);
 
136
    debugs(79, 3, "storeCossUnlink: offset " << e.swap_filen);
138
137
    StoreFScoss::GetInstance().stats.unlink.ops++;
139
138
    StoreFScoss::GetInstance().stats.unlink.success++;
140
139
    storeCossRemove(this, &e);
160
159
     * this one is kinda strange - Eric called allocate(), then
161
160
     * storeCossOpen(O_RDONLY) .. weird. Anyway, I'm allocating this now.
162
161
     */
163
 
    cstate->st_size = objectLen(&e) + e.mem_obj->swap_hdr_sz;
 
162
    cstate->st_size = e.objectLen() + e.mem_obj->swap_hdr_sz;
164
163
    sio->swap_dirn = index;
165
164
    sio->swap_filen = allocate(&e, COSS_ALLOC_ALLOCATE);
166
 
    debug(79, 3) ("storeCossCreate: offset %ld, size %ld, end %ld\n",
167
 
                  (long int) storeCossFilenoToDiskOffset(sio->swap_filen),
168
 
                  (long int) cstate->st_size,
169
 
                  (long int) (sio->swap_filen + cstate->st_size));
 
165
    debugs(79, 3, "storeCossCreate: offset " <<
 
166
           (long int) storeCossFilenoToDiskOffset(sio->swap_filen) <<
 
167
           ", size " << (long int) cstate->st_size << ", end " <<
 
168
           (long int) (sio->swap_filen + cstate->st_size));
 
169
 
170
170
    /* assume allocate() always succeeds */
171
171
    assert(-1 != sio->swap_filen);
172
172
 
196
196
    CossState *cstate;
197
197
    sfileno f = e.swap_filen;
198
198
 
199
 
    debug(79, 3) ("storeCossOpen: offset %d\n", f);
 
199
    debugs(79, 3, "storeCossOpen: offset " << f);
200
200
    StoreFScoss::GetInstance().stats.open.ops++;
201
201
 
202
202
    StoreIOState::Pointer sio = new CossState (this);
243
243
            /* We have to clean up neatly .. */
244
244
            StoreFScoss::GetInstance().stats.open.fail++;
245
245
            numcollisions++;
246
 
            debug(79, 2) ("storeCossOpen: Reallocation of %d/%d failed\n", e.swap_dirn, e.swap_filen);
 
246
            debugs(79, 2, "storeCossOpen: Reallocation of " << e.swap_dirn << "/" << e.swap_filen << " failed");
247
247
            /* XXX XXX XXX Will squid call storeUnlink for this object? */
248
248
            return NULL;
249
249
        }
278
278
void
279
279
CossState::close()
280
280
{
281
 
    debug(79, 3) ("storeCossClose: offset %d\n", swap_filen);
 
281
    debugs(79, 3, "storeCossClose: offset " << swap_filen);
282
282
 
283
283
    StoreFScoss::GetInstance().stats.close.ops++;
284
284
    StoreFScoss::GetInstance().stats.close.success++;
297
297
    assert(read.callback_data == NULL);
298
298
    read.callback = callback;
299
299
    read.callback_data = cbdataReference(callback_data);
300
 
    debug(79, 3) ("storeCossRead: offset %ld\n", (long int) offset);
 
300
    debugs(79, 3, "storeCossRead: offset " << offset);
301
301
    offset_ = offset;
302
302
    flags.reading = 1;
303
303
 
339
339
    assert(e->mem_obj->object_sz != -1);
340
340
    StoreFScoss::GetInstance().stats.write.ops++;
341
341
 
342
 
    debug(79, 3) ("storeCossWrite: offset %ld, len %lu\n", (long int) offset_, (unsigned long int) size);
 
342
    debugs(79, 3, "storeCossWrite: offset " << offset_ << ", len " << (unsigned long int) size);
343
343
    diskoffset = SD->storeCossFilenoToDiskOffset(swap_filen) + offset_;
344
344
    CossSwapDir *SD = (CossSwapDir *)INDEXSD(swap_dirn);
345
345
    dest = SD->storeCossMemPointerFromDiskOffset(diskoffset, &membuf);
421
421
{
422
422
    STIOCB *callback = this->callback;
423
423
    void *cbdata;
424
 
    debug(79, 3) ("CossState::doCallback: errflag=%d\n", errflag);
 
424
    debugs(79, 3, "CossState::doCallback: errflag=" << errflag);
425
425
    assert(NULL == locked_membuf);
426
426
    xfree(readbuffer);
427
427
    this->callback = NULL;
457
457
CossState::lockMemBuf()
458
458
{
459
459
    CossMemBuf *t = SD->storeCossFilenoToMembuf(swap_filen);
460
 
    debug(79, 3) ("CossState::lockMemBuf: locking %p, lockcount %d\n", t, t->lockcount);
 
460
    debugs(79, 3, "CossState::lockMemBuf: locking " << t << ", lockcount " << t->lockcount);
461
461
    locked_membuf = t;
462
462
    ++t->lockcount;
463
463
}
471
471
    if (NULL == t)
472
472
        return;
473
473
 
474
 
    debug(79, 3) ("storeCossMemBufUnlock: unlocking %p, lockcount %d\n", t, t->lockcount);
 
474
    debugs(79, 3, "storeCossMemBufUnlock: unlocking " << t << ", lockcount " << t->lockcount);
475
475
 
476
476
    t->lockcount--;
477
477
 
499
499
        t = (CossMemBuf *)m->data;
500
500
 
501
501
        if (t->flags.writing) {
502
 
            debug(79, 1) ("WARNING: sleeping for 5 seconds in storeCossSync()\n");
 
502
            debugs(79, 1, "WARNING: sleeping for 5 seconds in storeCossSync()");
503
503
            sleep(5);           /* XXX EEEWWW! */
504
504
        }
505
505
 
519
519
    describe(3, __LINE__);
520
520
 
521
521
    if (!flags.full)
522
 
        debug(79, 3) ("membuf %p not full\n", this);
 
522
        debugs(79, 3, "membuf " << this << " not full");
523
523
    else if (flags.writing)
524
 
        debug(79, 3) ("membuf %p writing\n", this);
 
524
        debugs(79, 3, "membuf " << this << " writing");
525
525
    else if (lockcount)
526
 
        debug(79, 3) ("membuf %p lockcount=%d\n", this, lockcount);
 
526
        debugs(79, 3, "membuf " << this << " lockcount=" << lockcount);
527
527
    else
528
528
        write(SD);
529
529
}
532
532
CossMemBuf::write(CossSwapDir * SD)
533
533
{
534
534
    StoreFScoss::GetInstance().stats.stripe_write.ops++;
535
 
    debug(79, 3) ("CossMemBuf::write: offset %ld, len %ld\n",
536
 
                  (long int) diskstart, (long int) (diskend - diskstart));
 
535
    debugs(79, 3, "CossMemBuf::write: offset " << diskstart << ", len " << (diskend - diskstart));
537
536
    flags.writing = 1;
538
537
    /* XXX Remember that diskstart/diskend are block offsets! */
539
538
    SD->theFile->write(new CossWrite(WriteRequest((char const *)&buffer, diskstart, diskend - diskstart, NULL), this));
551
550
    CBDATA_INIT_TYPE_FREECB(CossMemBuf, NULL);
552
551
    newmb = cbdataAlloc(CossMemBuf);
553
552
    newmb->diskstart = start;
554
 
    debug(79, 3) ("CossSwapDir::createMemBuf: creating new membuf at %ld\n", (long int) newmb->diskstart);
555
 
    debug(79, 3) ("CossSwapDir::createMemBuf: at %p\n", newmb);
 
553
    debugs(79, 3, "CossSwapDir::createMemBuf: creating new membuf at " << newmb->diskstart);
 
554
    debugs(79, 3, "CossSwapDir::createMemBuf: at " << newmb);
556
555
    newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ;
557
556
    newmb->flags.full = 0;
558
557
    newmb->flags.writing = 0;
563
562
 
564
563
    /* Print out the list of membufs */
565
564
 
566
 
    debug(79, 3) ("CossSwapDir::createMemBuf: membuflist:\n");
 
565
    debugs(79, 3, "CossSwapDir::createMemBuf: membuflist:");
567
566
 
568
567
    for (m = membufs.head; m; m = m->next) {
569
568
        t = (CossMemBuf *)m->data;
590
589
    }
591
590
 
592
591
    if (numreleased > 0)
593
 
        debug(79, 3) ("CossSwapDir::createMemBuf: this allocation released %d storeEntries\n", numreleased);
 
592
        debugs(79, 3, "CossSwapDir::createMemBuf: this allocation released " << numreleased << " storeEntries");
594
593
 
595
594
    StoreFScoss::GetInstance().stats.stripes++;
596
595
 
618
617
void
619
618
CossMemBuf::describe(int level, int line)
620
619
{
621
 
    debug(79, level) ("membuf %p, LC:%02d, ST:%010lu, FL:%c%c\n",
622
 
                      this,
623
 
                      lockcount,
624
 
                      (unsigned long) diskstart,
625
 
                      flags.full ? 'F' : '.',
626
 
                      flags.writing ? 'W' : '.');
 
620
     debugs(79, level, "membuf " << this << ", LC:" << std::setfill('0') <<  
 
621
            std::setw(2) << lockcount << ", ST:" << 
 
622
            std::setw(10) <<  (unsigned long) diskstart << ", FL:" << 
 
623
            (flags.full ? 'F' : '.') << (flags.writing ? 'W' : '.'));
627
624
}
628
625