From: Lachlan McIlroy <lmcilroy@redhat.com>
To: Felix Blyakher <felixb@sgi.com>
Cc: Eric Sandeen <sandeen@sandeen.net>, xfs@oss.sgi.com
Subject: Re: [PATCH] xfs_file_last_byte() needs to acquire ilock
Date: Tue, 28 Apr 2009 00:11:36 -0400 (EDT) [thread overview]
Message-ID: <860553965.233621240891896139.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <1913401106.233581240891740242.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
----- "Felix Blyakher" <felixb@sgi.com> wrote:
> On Apr 23, 2009, at 10:46 PM, Lachlan McIlroy wrote:
>
> >
> > ----- "Eric Sandeen" <sandeen@sandeen.net> wrote:
> >
> >> Lachlan McIlroy wrote:
> >>> We had some systems crash with this stack:
> >>>
> >>> [<a00000010000cb20>] ia64_leave_kernel+0x0/0x280
> >>> [<a00000021291ca00>] xfs_bmbt_get_startoff+0x0/0x20 [xfs]
> >>> [<a0000002129080b0>] xfs_bmap_last_offset+0x210/0x280 [xfs]
> >>> [<a00000021295b010>] xfs_file_last_byte+0x70/0x1a0 [xfs]
> >>> [<a00000021295b200>] xfs_itruncate_start+0xc0/0x1a0 [xfs]
> >>> [<a0000002129935f0>] xfs_inactive_free_eofblocks+0x290/0x460
> [xfs]
> >>> [<a000000212998fb0>] xfs_release+0x1b0/0x240 [xfs]
> >>> [<a0000002129ad930>] xfs_file_release+0x70/0xa0 [xfs]
> >>> [<a000000100162ea0>] __fput+0x1a0/0x420
> >>> [<a000000100163160>] fput+0x40/0x60
> >>>
> >>> The problem here is that xfs_file_last_byte() does not acquire
> the
> >>> inode lock and can therefore race with another thread that is
> >> modifying
> >>> the extext list. While xfs_bmap_last_offset() is trying to
> lookup
> >>> what was the last extent some extents were merged and the extent
> >> list
> >>> shrunk so the index we lookup is now beyond the end of the extent
> >> list
> >>> and potentially in a freed buffer.
> >>>
> >>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> >>> index e7ae08d..cf62d9d 100644
> >>> --- a/fs/xfs/xfs_inode.c
> >>> +++ b/fs/xfs/xfs_inode.c
> >>> @@ -1258,8 +1258,10 @@ xfs_file_last_byte(
> >>
> >> /*
> >> * Only check for blocks beyond the EOF if the extents have
> >> * been read in. This eliminates the need for the inode
> >> lock,
> >> * and it also saves us from looking when it really isn't
> >>> * necessary.
> >>> */
> >>
> >> I suppose that comment should be modified too, and maybe the
> commit
> >> log
> >> should say why, exactly, it was wrong? :)
> > Ha, I didn't even read the comment! It's still kind of correct in
> > that we wont have to get the inode lock if the extents have not
> been
> >
> > read in.
>
> I'd still think the comments could be made less confusing
> if we're adding the inode lock here.
The more I read the comment the more it makes sense and it seems to
make more sense now with the change because it is clear how we can
avoid the inode lock if the extents are not read in.
How would you prefer the comment reads?
>
> Felix
>
> >
> >
> >>
> >> -Eric
> >>
> >>> if (ip->i_df.if_flags & XFS_IFEXTENTS) {
> >>> + xfs_ilock(ip, XFS_ILOCK_SHARED);
> >>> error = xfs_bmap_last_offset(NULL, ip, &last_block,
> >>> XFS_DATA_FORK);
> >>> + xfs_iunlock(ip, XFS_ILOCK_SHARED);
> >>> if (error) {
> >>> last_block = 0;
> >>> }
> >>>
> >>> _______________________________________________
> >>> xfs mailing list
> >>> xfs@oss.sgi.com
> >>> http://oss.sgi.com/mailman/listinfo/xfs
> >>>
> >>
> >> _______________________________________________
> >> xfs mailing list
> >> xfs@oss.sgi.com
> >> http://oss.sgi.com/mailman/listinfo/xfs
> >
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next parent reply other threads:[~2009-04-28 4:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1913401106.233581240891740242.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-04-28 4:11 ` Lachlan McIlroy [this message]
2009-04-28 5:03 ` [PATCH] xfs_file_last_byte() needs to acquire ilock Felix Blyakher
2009-04-28 5:33 ` Lachlan McIlroy
2009-04-28 14:34 ` Felix Blyakher
[not found] <869141559.5581240549433363.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-04-24 5:07 ` Lachlan McIlroy
[not found] <344266684.4811240544710893.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-04-24 3:46 ` Lachlan McIlroy
2009-04-24 21:42 ` Felix Blyakher
2009-04-24 2:18 Lachlan McIlroy
2009-04-24 2:49 ` Eric Sandeen
2009-04-24 4:25 ` Felix Blyakher
2009-04-24 17:52 ` Christoph Hellwig
2009-04-24 19:30 ` Felix Blyakher
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=860553965.233621240891896139.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com \
--to=lmcilroy@redhat.com \
--cc=felixb@sgi.com \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox