From: Andrea Arcangeli <andrea@suse.de>
To: Christoph Hellwig <hch@infradead.org>,
linux-kernel@vger.kernel.org, lord@sgi.com
Subject: Re: 2.4.20pre5aa1
Date: Thu, 5 Sep 2002 20:59:17 +0200 [thread overview]
Message-ID: <20020905185917.GG1657@dualathlon.random> (raw)
In-Reply-To: <20020905194649.A11789@infradead.org>
On Thu, Sep 05, 2002 at 07:46:49PM +0100, Christoph Hellwig wrote:
> On Thu, Sep 05, 2002 at 08:41:25PM +0200, Andrea Arcangeli wrote:
> > maybe I'm overlooking something but after a short read it seems you have
> > no lock in do_truncate->setattr like for all the other fs, so the
> > vmtruncate can run under reads and the i_size can change under you and
> > in turn you must always read it with i_size_read using asm, like all the
> > other fs, if you're not holding the i_sem (and you certainly aren't
> > holding the i_sem that frequently, you don't even for writes). this
> > because i_sem is the only lock/sem hold by truncate. Infact I'm unsure
> > how you serialize the i_size writes of truncate against the ones from
> > writes, that seems problematic too, the i_size could get a value past
> > the last block allocated (in turn corrupting the fs). Please double
> > check that I'm wrong, thanks.
>
> I think we should take the XFS-specific inode lock around vmtruncate.
> Need to double-check with Steve.
this is the function I'm looking at and it's called with xfs specific
inode lock, and I don't see it grabbed either before calling vmtruncate:
+STATIC int
+linvfs_setattr(
+ struct dentry *dentry,
+ struct iattr *attr)
+{
+ struct inode *inode = dentry->d_inode;
+ vnode_t *vp = LINVFS_GET_VP(inode);
+ vattr_t vattr;
+ unsigned int ia_valid = attr->ia_valid;
+ int error;
+ int flags = 0;
+
+ memset(&vattr, 0, sizeof(vattr_t));
+ if (ia_valid & ATTR_UID) {
+ vattr.va_mask |= AT_UID;
+ vattr.va_uid = attr->ia_uid;
+ }
+ if (ia_valid & ATTR_GID) {
+ vattr.va_mask |= AT_GID;
+ vattr.va_gid = attr->ia_gid;
+ }
+ if (ia_valid & ATTR_SIZE) {
+ vattr.va_mask |= AT_SIZE;
+ vattr.va_size = attr->ia_size;
+ }
+ if (ia_valid & ATTR_ATIME) {
+ vattr.va_mask |= AT_ATIME;
+ vattr.va_atime.tv_sec = attr->ia_atime;
+ vattr.va_atime.tv_nsec = 0;
+ }
+ if (ia_valid & ATTR_MTIME) {
+ vattr.va_mask |= AT_MTIME;
+ vattr.va_mtime.tv_sec = attr->ia_mtime;
+ vattr.va_mtime.tv_nsec = 0;
+ }
+ if (ia_valid & ATTR_CTIME) {
+ vattr.va_mask |= AT_CTIME;
+ vattr.va_ctime.tv_sec = attr->ia_ctime;
+ vattr.va_ctime.tv_nsec = 0;
+ }
+ if (ia_valid & ATTR_MODE) {
+ vattr.va_mask |= AT_MODE;
+ vattr.va_mode = attr->ia_mode;
+ if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
+ inode->i_mode &= ~S_ISGID;
+ }
+
+ if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))
+ flags = ATTR_UTIME;
+
+ VOP_SETATTR(vp, &vattr, flags, NULL, error);
+ if (error)
+ return(-error); /* Positive error up from XFS */
+ if (ia_valid & ATTR_SIZE) {
+ error = vmtruncate(inode, attr->ia_size);
+ }
+
+ if (!error) {
+ vn_revalidate(vp, 0);
+ mark_inode_dirty_sync(inode);
+ }
+ return error;
+}
Andrea
next prev parent reply other threads:[~2002-09-05 18:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-04 23:35 2.4.20pre5aa1 Andrea Arcangeli
2002-09-04 23:56 ` 2.4.20pre5aa1 Andrew Morton
2002-09-05 0:25 ` 2.4.20pre5aa1 Andrea Arcangeli
2002-09-05 12:44 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 16:53 ` 2.4.20pre5aa1 Andrea Arcangeli
2002-09-05 17:09 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 18:41 ` 2.4.20pre5aa1 Andrea Arcangeli
2002-09-05 18:46 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 18:59 ` Andrea Arcangeli [this message]
2002-09-05 19:02 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 19:13 ` 2.4.20pre5aa1 Andrea Arcangeli
2002-09-05 19:17 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 18:48 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 19:06 ` 2.4.20pre5aa1 Andrea Arcangeli
2002-09-05 19:15 ` 2.4.20pre5aa1 Christoph Hellwig
2002-09-05 19:26 ` 2.4.20pre5aa1 Christoph Hellwig
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=20020905185917.GG1657@dualathlon.random \
--to=andrea@suse.de \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lord@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.