Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
From: ronnie sahlberg <ronniesahlberg@gmail.com>
To: Steve French <smfrench@gmail.com>
Cc: Ronnie Sahlberg <lsahlber@redhat.com>,
	linux-cifs <linux-cifs@vger.kernel.org>
Subject: Re: [PATCH] cifs: add support for fallocate mode 0 for non-sparse files
Date: Thu, 16 Jan 2020 18:42:28 +1000
Message-ID: <CAN05THRbNrd=ZmSMO4yE8oHD3Xn93zNTMBRXnJBuf7J3C5Cmow@mail.gmail.com> (raw)
In-Reply-To: <CAH2r5mumEjNcCT=Dc4CMatjprWgBDGVS-3nsds2QqPoZMs8xZQ@mail.gmail.com>

The bug is basically that if we extend a file by fallocate mode==0
and immediately afterwards mmap() the file we will only mmap() as much
as end-of-file was
prior to the truncate  and then if we try to touch any
address in this extended region userspace dies with bus error.

The patch added "extend a file with fallocate mode==0 for NON-Sparse
files" and caused xfstest to fail.
The fix is to force us to revalidate the file attributes (the size is
the important one) when we extend the file so
mmap() will work properly.
I have fixed this in the patch and will resend tomorrow after some more testing.

Looking for other SMB2_set_eof() callsites I see we already had the
same bug for the case of extending a SPARSE
file using fallocate mode==0. I fixed that too and will audit all
other plases where we use SMB2_set_eof()
to see if they are safe or not before resending.


On Thu, Jan 16, 2020 at 12:33 PM Steve French <smfrench@gmail.com> wrote:
>
> temporarily removed to allow Ronnie to debug a test failure
>
> On Wed, Jan 15, 2020 at 2:14 PM Steve French <smfrench@gmail.com> wrote:
> >
> > Tentatively merged into cifs-2.6.git for-next pending more testing
> >
> > On Tue, Jan 14, 2020 at 8:25 PM ronnie sahlberg
> > <ronniesahlberg@gmail.com> wrote:
> > >
> > > On Wed, Jan 15, 2020 at 11:25 AM Steve French <smfrench@gmail.com> wrote:
> > > >
> > > > Does it affect (or enable) any xfstests?
> > >
> > > It shouldn't affect any current tests.
> > > It adds support for
> > >    xfs_io -c "falloc 0 512M" <file>
> > >
> > > generic/071 now passes with this patch.   Possibly other tests as well
> > > that use "xfs_io -c falloc" as well
> > >
> > >
> > > >
> > > > On Tue, Jan 14, 2020 at 7:23 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
> > > > >
> > > > > RHBZ 1336264
> > > > >
> > > > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> > > > > ---
> > > > >  fs/cifs/smb2ops.c | 10 +++++++---
> > > > >  1 file changed, 7 insertions(+), 3 deletions(-)
> > > > >
> > > > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> > > > > index 6250370c1170..91818f7c1b9c 100644
> > > > > --- a/fs/cifs/smb2ops.c
> > > > > +++ b/fs/cifs/smb2ops.c
> > > > > @@ -3106,9 +3106,13 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
> > > > >                 else if (i_size_read(inode) >= off + len)
> > > > >                         /* not extending file and already not sparse */
> > > > >                         rc = 0;
> > > > > -               /* BB: in future add else clause to extend file */
> > > > > -               else
> > > > > -                       rc = -EOPNOTSUPP;
> > > > > +               /* extend file */
> > > > > +               else {
> > > > > +                       eof = cpu_to_le64(off + len);
> > > > > +                       rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
> > > > > +                                         cfile->fid.volatile_fid, cfile->pid,
> > > > > +                                         &eof);
> > > > > +               }
> > > > >                 if (rc)
> > > > >                         trace_smb3_falloc_err(xid, cfile->fid.persistent_fid,
> > > > >                                 tcon->tid, tcon->ses->Suid, off, len, rc);
> > > > > --
> > > > > 2.13.6
> > > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > >
> > > > Steve
> >
> >
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve

  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15  1:23 [PATCH 0/1] add support for fallocate mode 0 Ronnie Sahlberg
2020-01-15  1:23 ` [PATCH] cifs: add support for fallocate mode 0 for non-sparse files Ronnie Sahlberg
2020-01-15  1:25   ` Steve French
2020-01-15  2:25     ` ronnie sahlberg
2020-01-15 20:14       ` Steve French
2020-01-16  2:03         ` Steve French
2020-01-16  8:42           ` ronnie sahlberg [this message]
2020-01-17  0:27             ` Pavel Shilovsky
2020-01-17  0:56               ` ronnie sahlberg
2020-01-17  0:04 Ronnie Sahlberg
2020-01-17  1:15 Ronnie Sahlberg

Reply instructions:

You may reply publically 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='CAN05THRbNrd=ZmSMO4yE8oHD3Xn93zNTMBRXnJBuf7J3C5Cmow@mail.gmail.com' \
    --to=ronniesahlberg@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=smfrench@gmail.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

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git