In message <20080501170819.bdcb9035.akpm@linux-foundation.org>, Andrew Morton writes:
[...]
If i_blocks is indeed less important than i_size, then we can live with some
incoherency b/t i_size and i_blocks, for now. Nevertheless, I propose
adding this to linux/fs.h:
static inline blkcnt_t i_blocks_read(const struct inode *inode)
{
#if BITS_PER_LONG == 32
blkcnt_t i_blocks;
spin_lock(&src->i_lock);
i_blocks = src->i_blocks;
spin_unlock(&src->i_lock);
return i_blocks;
#else
return src->i_blocks;
#endif
}
and a matching i_blocks_write function. We can then gradually convert those
"unsafe" users of i_blocks to use the new i_blocks_read/write helpers.
The nice thing about these two helpers is fsstack_copy_inode_size becomes a
lot cleaner and more elegant:
void fsstack_copy_inode_size(struct inode *dst, struct inode *src)
{
i_blocks_write(dst, i_blocks_read(src));
i_size_write(dst, i_size_read(src));
}
And, if we ever wanted to ensure coherency b/t i_blocks and i_size, we'll
need to create helpers that merge the functionality of i_size_read/write and
i_blocks_read/write.
What do you think?
Erez.
--