From: Miklos Szeredi Subject: [patch 02/12] document i_size_write locking rules Date: Mon, 16 Oct 2006 18:27:11 +0200 Message-ID: <20061016162731.445990000@szeredi.hu> References: <20061016162709.369579000@szeredi.hu> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Return-path: Received: from mail-gw1.sa.eol.hu ([212.108.200.67]:18633 "EHLO mail-gw1.sa.eol.hu") by vger.kernel.org with ESMTP id S1422730AbWJPQ2O (ORCPT ); Mon, 16 Oct 2006 12:28:14 -0400 To: akpm@osdl.org Content-Disposition: inline; filename=document_i_size_write_locking.patch Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 --- 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) --