* [PATCH] CIFS: check new file size when extending file by fallocate
@ 2020-03-18 1:56 Murphy Zhou
2020-03-18 2:01 ` ronnie sahlberg
2020-03-18 5:57 ` Steve French
0 siblings, 2 replies; 4+ messages in thread
From: Murphy Zhou @ 2020-03-18 1:56 UTC (permalink / raw)
To: linux-cifs; +Cc: Ronnie Sahlberg, Steve French
xfstests generic/228 checks if fallocate respects RLIMIT_FSIZE.
After fallocate mode 0 extending enabled, cifs can hit this failure.
Fix this by checking the new file size with the vfs helper, which
checks with RLIMIT_FSIZE(ulimit -f) and s_maxbytes.
This patch has been tested by LTP/xfstests aginst samba and
Windows server. No new issue was found.
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
fs/cifs/smb2ops.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index c31e84ee3c39..48bbbb68540d 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -3246,10 +3246,14 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
* Extending the file
*/
if ((keep_size == false) && i_size_read(inode) < off + len) {
+ eof = cpu_to_le64(off + len);
+ rc = inode_newsize_ok(inode, eof);
+ if (rc)
+ goto out;
+
if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)
smb2_set_sparse(xid, tcon, cfile, inode, false);
- 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 == 0) {
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] CIFS: check new file size when extending file by fallocate
2020-03-18 1:56 [PATCH] CIFS: check new file size when extending file by fallocate Murphy Zhou
@ 2020-03-18 2:01 ` ronnie sahlberg
2020-03-18 5:57 ` Steve French
1 sibling, 0 replies; 4+ messages in thread
From: ronnie sahlberg @ 2020-03-18 2:01 UTC (permalink / raw)
To: Murphy Zhou; +Cc: linux-cifs, Ronnie Sahlberg, Steve French
Looks good.
Ackd-by: me
On Wed, Mar 18, 2020 at 11:57 AM Murphy Zhou <jencce.kernel@gmail.com> wrote:
>
> xfstests generic/228 checks if fallocate respects RLIMIT_FSIZE.
> After fallocate mode 0 extending enabled, cifs can hit this failure.
> Fix this by checking the new file size with the vfs helper, which
> checks with RLIMIT_FSIZE(ulimit -f) and s_maxbytes.
>
> This patch has been tested by LTP/xfstests aginst samba and
> Windows server. No new issue was found.
>
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> ---
> fs/cifs/smb2ops.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index c31e84ee3c39..48bbbb68540d 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -3246,10 +3246,14 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
> * Extending the file
> */
> if ((keep_size == false) && i_size_read(inode) < off + len) {
> + eof = cpu_to_le64(off + len);
> + rc = inode_newsize_ok(inode, eof);
> + if (rc)
> + goto out;
> +
> if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)
> smb2_set_sparse(xid, tcon, cfile, inode, false);
>
> - 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 == 0) {
> --
> 2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] CIFS: check new file size when extending file by fallocate
2020-03-18 1:56 [PATCH] CIFS: check new file size when extending file by fallocate Murphy Zhou
2020-03-18 2:01 ` ronnie sahlberg
@ 2020-03-18 5:57 ` Steve French
2020-03-18 11:27 ` Murphy Zhou
1 sibling, 1 reply; 4+ messages in thread
From: Steve French @ 2020-03-18 5:57 UTC (permalink / raw)
To: Murphy Zhou; +Cc: CIFS, Ronnie Sahlberg, Steve French
generates a warning (sparse) when compiled - can you fix and resubmit
(can also add Ronnie's acked if you want)
CHECK /home/smfrench/cifs-2.6/fs/cifs/smb2ops.c
/home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: warning: incorrect
type in argument 2 (different base types)
/home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: expected long
long [usertype] offset
/home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: got restricted
__le64 [assigned] [usertype] eof
CC [M] /home/smfrench/cifs-2.6/fs/cifs/smb2ops.o
On Tue, Mar 17, 2020 at 8:57 PM Murphy Zhou <jencce.kernel@gmail.com> wrote:
>
> xfstests generic/228 checks if fallocate respects RLIMIT_FSIZE.
> After fallocate mode 0 extending enabled, cifs can hit this failure.
> Fix this by checking the new file size with the vfs helper, which
> checks with RLIMIT_FSIZE(ulimit -f) and s_maxbytes.
>
> This patch has been tested by LTP/xfstests aginst samba and
> Windows server. No new issue was found.
>
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> ---
> fs/cifs/smb2ops.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index c31e84ee3c39..48bbbb68540d 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -3246,10 +3246,14 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
> * Extending the file
> */
> if ((keep_size == false) && i_size_read(inode) < off + len) {
> + eof = cpu_to_le64(off + len);
> + rc = inode_newsize_ok(inode, eof);
> + if (rc)
> + goto out;
> +
> if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)
> smb2_set_sparse(xid, tcon, cfile, inode, false);
>
> - 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 == 0) {
> --
> 2.20.1
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] CIFS: check new file size when extending file by fallocate
2020-03-18 5:57 ` Steve French
@ 2020-03-18 11:27 ` Murphy Zhou
0 siblings, 0 replies; 4+ messages in thread
From: Murphy Zhou @ 2020-03-18 11:27 UTC (permalink / raw)
To: Steve French; +Cc: Murphy Zhou, CIFS, Ronnie Sahlberg, Steve French
On Wed, Mar 18, 2020 at 12:57:23AM -0500, Steve French wrote:
> generates a warning (sparse) when compiled - can you fix and resubmit
> (can also add Ronnie's acked if you want)
Sure. Will send v2.
Thanks!
>
> CHECK /home/smfrench/cifs-2.6/fs/cifs/smb2ops.c
> /home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: warning: incorrect
> type in argument 2 (different base types)
> /home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: expected long
> long [usertype] offset
> /home/smfrench/cifs-2.6/fs/cifs/smb2ops.c:3259:46: got restricted
> __le64 [assigned] [usertype] eof
> CC [M] /home/smfrench/cifs-2.6/fs/cifs/smb2ops.o
>
> On Tue, Mar 17, 2020 at 8:57 PM Murphy Zhou <jencce.kernel@gmail.com> wrote:
> >
> > xfstests generic/228 checks if fallocate respects RLIMIT_FSIZE.
> > After fallocate mode 0 extending enabled, cifs can hit this failure.
> > Fix this by checking the new file size with the vfs helper, which
> > checks with RLIMIT_FSIZE(ulimit -f) and s_maxbytes.
> >
> > This patch has been tested by LTP/xfstests aginst samba and
> > Windows server. No new issue was found.
> >
> > Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> > ---
> > fs/cifs/smb2ops.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> > index c31e84ee3c39..48bbbb68540d 100644
> > --- a/fs/cifs/smb2ops.c
> > +++ b/fs/cifs/smb2ops.c
> > @@ -3246,10 +3246,14 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
> > * Extending the file
> > */
> > if ((keep_size == false) && i_size_read(inode) < off + len) {
> > + eof = cpu_to_le64(off + len);
> > + rc = inode_newsize_ok(inode, eof);
> > + if (rc)
> > + goto out;
> > +
> > if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0)
> > smb2_set_sparse(xid, tcon, cfile, inode, false);
> >
> > - 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 == 0) {
> > --
> > 2.20.1
>
>
>
> --
> Thanks,
>
> Steve
--
Murphy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-18 11:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 1:56 [PATCH] CIFS: check new file size when extending file by fallocate Murphy Zhou
2020-03-18 2:01 ` ronnie sahlberg
2020-03-18 5:57 ` Steve French
2020-03-18 11:27 ` Murphy Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).