lkml.org 
[lkml]   [2002]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] dm.c - device-mapper I/O path fixes
    Date
    On Wednesday 11 December 2002 13:19, Denis Vlasenko wrote:
    > On 11 December 2002 11:16, Kevin Corry wrote:
    > > > > --- diff/drivers/md/dm.c 2002-12-11 12:00:29.000000000 +0000
    > > > > +++ source/drivers/md/dm.c 2002-12-11 12:00:34.000000000 +0000
    > > > > @@ -238,10 +238,11 @@
    > > > > static spinlock_t _uptodate_lock = SPIN_LOCK_UNLOCKED;
    > > > > unsigned long flags;
    > > > >
    > > > > - spin_lock_irqsave(&_uptodate_lock, flags);
    > > > > - if (error)
    > > > > + if (error) {
    > > > > + spin_lock_irqsave(&_uptodate_lock, flags);
    > > > > io->error = error;
    > > > > - spin_unlock_irqrestore(&_uptodate_lock, flags);
    > > > > + spin_unlock_irqrestore(&_uptodate_lock, flags);
    > > > > + }
    > > > >
    > > > > if (atomic_dec_and_test(&io->io_count)) {
    > > > > if (atomic_dec_and_test(&io->md->pending))
    > > >
    > > > This seems pointless, end result:
    > > >
    > > > spin_lock_irqsave(&_uptodate_lock, flags);
    > > > io->error = error;
    > > > spin_unlock_irqrestore(&_uptodate_lock, flags);
    > >
    > > Are you saying the "if (error)" part is pointless? If so, I have to
    >
    > No. Locking is pointless. What exactly you try to protect here?

    The "struct dm_io *io" that is passed to dec_pending() can be accessed by
    multiple threads at the same time, thus some form of locking is required.

    I had been thinking about whether the "error" field could be an atomic_t,
    which would remove the requirement for the spinlock in dec_pending().
    However, I don't know how atomic_t's behave with negative values. I know
    atomic_t's are only guaranteed to have 24-bits of precision, yet all arch's
    define atomic_t with a signed integer. Can anyone enlighten me on this?

    Perhaps we could make "error" and atomic_t, and store the absolute-value of
    the error code, and always return -error in the bio_endio() call. Or is that
    just too ugly?

    --
    Kevin Corry
    corryk@us.ibm.com
    http://evms.sourceforge.net/
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:31    [W:0.022 / U:88.444 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site