From: Christoph Hellwig <hch@lst.de>
To: akpm@osdl.org, mmontour@bycast.com
Cc: roehrich@sgi.com, linux-fsdevel@vger.kernel.org
Subject: [PATCH] fix ->setattr ATTR_SIZE locking for nfsd
Date: Thu, 6 Jan 2005 18:33:28 +0100 [thread overview]
Message-ID: <20050106173328.GA25506@lst.de> (raw)
Since the big direct I/O rework do_truncate takes i_alloc_sem before
calling into ->setattr. Unfortunately the other callers of ->setattr
with ATTR_SIZE, most notably nfsd don't take it.
The (out of tree) XFS dmapi code relies wants to release i_alloc_sem and
thus gets into problems like
http://oss.sgi.com/bugzilla/show_bug.cgi?id=365
This patch moves acquiring and releasing i_alloc_sem into
notify_change() to make the locking behaviour consistant.
Index: fs/attr.c
===================================================================
RCS file: /cvs/linux-2.6-xfs/fs/attr.c,v
retrieving revision 1.2
diff -u -p -r1.2 attr.c
--- fs/attr.c 16 Aug 2004 03:52:41 -0000 1.2
+++ fs/attr.c 6 Jan 2005 04:55:14 -0000
@@ -167,6 +167,9 @@ int notify_change(struct dentry * dentry
if (!attr->ia_valid)
return 0;
+ if (ia_valid & ATTR_SIZE)
+ down_write(&dentry->d_inode->i_alloc_sem);
+
if (inode->i_op && inode->i_op->setattr) {
error = security_inode_setattr(dentry, attr);
if (!error)
@@ -183,6 +186,10 @@ int notify_change(struct dentry * dentry
error = inode_setattr(inode, attr);
}
}
+
+ if (ia_valid & ATTR_SIZE)
+ up_write(&dentry->d_inode->i_alloc_sem);
+
if (!error) {
unsigned long dn_mask = setattr_mask(ia_valid);
if (dn_mask)
Index: fs/open.c
===================================================================
RCS file: /cvs/linux-2.6-xfs/fs/open.c,v
retrieving revision 1.7
diff -u -p -r1.7 open.c
--- fs/open.c 16 Aug 2004 03:52:41 -0000 1.7
+++ fs/open.c 6 Jan 2005 04:55:15 -0000
@@ -202,10 +202,9 @@ int do_truncate(struct dentry *dentry, l
newattrs.ia_size = length;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+
down(&dentry->d_inode->i_sem);
- down_write(&dentry->d_inode->i_alloc_sem);
err = notify_change(dentry, &newattrs);
- up_write(&dentry->d_inode->i_alloc_sem);
up(&dentry->d_inode->i_sem);
return err;
}
reply other threads:[~2005-01-06 17:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050106173328.GA25506@lst.de \
--to=hch@lst.de \
--cc=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mmontour@bycast.com \
--cc=roehrich@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.