lkml.org 
[lkml]   [2008]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: fs_stack/eCryptfs: remove 3rd arg of copy_attr_all, add locking to copy_inode_size
In message <20080403182001.GB30189@josefsipek.net>, "Josef 'Jeff' Sipek" writes:
> On Wed, Apr 02, 2008 at 09:49:11PM -0400, Erez Zadok wrote:
> ...
> > +#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
> > + spin_lock(&dst->i_lock);
> > +#endif
>
> I think you need to check CONFIG_PREEMPT as well.
>
> Josef 'Jeff' Sipek.

I'm not sure if it's needed in case of CONFIG_PREEMPT. Anyone? The code
for i_size_write (below), and the comment at the top of the function,
suggest that the spinlock is needed only to prevent the lots seqcount.

/*
* NOTE: unlike i_size_read(), i_size_write() does need locking around it
* (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount
* can be lost, resulting in subsequent i_size_read() calls spinning forever.
*/
static inline void i_size_write(struct inode *inode, loff_t i_size)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
write_seqcount_begin(&inode->i_size_seqcount);
inode->i_size = i_size;
write_seqcount_end(&inode->i_size_seqcount);
#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
preempt_disable();
inode->i_size = i_size;
preempt_enable();
#else
inode->i_size = i_size;
#endif
}

BTW, some time ago I reviewed all callers of i_size_write. I did so again
just now, and the results were the same:

- a LOT of callers of i_size_write don't take any lock
- some take another spinlock in a different data structure
- those that do take the spinlock, do so unconditionally
- only unionfs and fs/stack.c wrap the spinlock in

#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)

Erez.


\
 
 \ /
  Last update: 2008-04-03 21:09    [from the cache]
©2003-2011 Jasper Spaans