[patch 02/12] document i_size_write locking rules

From: Miklos Szeredi
Date: Mon Oct 16 2006 - 12:29:01 EST


Unless someone reads the documentation for write_seqcount_{begin,end}
it is not obvious, that i_size_write() needs locking. Especially,
that lack of such locking can result in a system hang.

Signed-off-by: Miklos Szeredi <miklos@xxxxxxxxxx>

---
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h 2006-10-16 12:53:03.000000000 +0200
+++ linux/include/linux/fs.h 2006-10-16 14:10:22.000000000 +0200
@@ -670,7 +670,11 @@ static inline loff_t i_size_read(struct
#endif
}

-
+/*
+ * 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)

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/