From: Eryu Guan <eguan@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfsdump: fix race condition between lseek() and read()/write()
Date: Thu, 13 Jul 2017 15:28:48 +0800 [thread overview]
Message-ID: <20170713072848.GD2478@eguan.usersys.redhat.com> (raw)
In-Reply-To: <a63c9311-8b97-ad31-63cb-35bdea02b6a3@sandeen.net>
On Wed, Jul 12, 2017 at 03:56:00PM -0500, Eric Sandeen wrote:
> Hm, but isn't this a problem?
/me rewinds my mind by 15 months and confirms it is a problem :)
>
> On 04/21/2016 08:06 AM, Eryu Guan wrote:
> > diff --git a/inventory/inv_core.c b/inventory/inv_core.c
> > index a17c2c9..42d0ac4 100644
> > --- a/inventory/inv_core.c
> > +++ b/inventory/inv_core.c
> > @@ -121,19 +121,10 @@ get_invtrecord( int fd, void *buf, size_t bufsz, off64_t off,
> > if ( dolock )
> > INVLOCK( fd, LOCK_SH );
> >
> > - if ( lseek( fd, (off_t)off, whence ) < 0 ) {
>
> whence can be _SET or _CUR depending on the caller, but with this
> patch whence is no longer used, and -
>
> > - INV_PERROR( _("Error in reading inventory record "
> > - "(lseek failed): ") );
> > - if ( dolock )
> > - INVLOCK( fd, LOCK_UN );
> > - return -1;
> > - }
> > -
> > - nread = read( fd, buf, bufsz );
> > -
> > + nread = pread(fd, buf, bufsz, (off_t)off);
>
> This is only equivalent to SET, no? With the other changes, perhaps we're
Yes, it's only equivalent to SET.
> no longer called via GET_REC_SEEKCUR - but in that case, the whence arg should
> be removed? Except for that pesky test code which explicitly passes SEEK_CUR ...
Agreed, the whence arg can be removed, the test code requires some
updates though.
I'm now testing a new version, I'll post it once it passes '-g dump'
tests.
Thanks for the review!
Eryu
>
>
> -Eric
>
> > if ( nread != (int) bufsz ) {
> > INV_PERROR( _("Error in reading inventory record :") );
> > - if ( dolock )
> > + if ( dolock )
> > INVLOCK( fd, LOCK_UN );
> > return -1;
> > }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-13 7:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 13:06 [PATCH] xfsdump: fix race condition between lseek() and read()/write() Eryu Guan
2017-03-27 20:20 ` Darrick J. Wong
2017-03-28 3:41 ` Eryu Guan
2017-07-12 18:26 ` Darrick J. Wong
2017-07-12 18:46 ` Eric Sandeen
2017-07-12 19:33 ` Eric Sandeen
2017-07-12 20:56 ` Eric Sandeen
2017-07-13 7:28 ` Eryu Guan [this message]
2017-07-13 8:41 ` [PATCH v2] " Eryu Guan
2017-07-13 20:10 ` Eric Sandeen
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=20170713072848.GD2478@eguan.usersys.redhat.com \
--to=eguan@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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