login
Header Space

 
 

Re: fs_stack/eCryptfs: remove 3rd arg of copy_attr_all, add locking to copy_inode_size

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Josef 'Jeff' Sipek <jeffpc@...>
Cc: Erez Zadok <ezk@...>, <akpm@...>, <linux-fsdevel@...>, <linux-kernel@...>, Al Viro <viro@...>, <hch@...>
Date: Thursday, April 3, 2008 - 3:07 pm

In message <20080403182001.GB30189@josefsipek.net>, "Josef 'Jeff' Sipek" writes:

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.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: fs_stack/eCryptfs: remove 3rd arg of copy_attr_all, add ..., Josef 'Jeff' Sipek, (Thu Apr 3, 2:20 pm)
Re: fs_stack/eCryptfs: remove 3rd arg of copy_attr_all, add ..., Erez Zadok, (Thu Apr 3, 3:07 pm)
Re: fs_stack/eCryptfs: remove 3rd arg of copy_attr_all, add ..., Josef 'Jeff' Sipek, (Thu Apr 3, 3:31 pm)
speck-geostationary