From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hr2.samba.org ([144.76.82.148]:33690 "EHLO hr2.samba.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966305AbeEJQzC (ORCPT ); Thu, 10 May 2018 12:55:02 -0400 Date: Thu, 10 May 2018 09:37:17 -0700 From: Jeremy Allison To: Steve French Cc: CIFS , linux-fsdevel , samba-technical Subject: Re: [PATCH] cifs/smb3: directory sync should not return an error Message-ID: <20180510163717.GA23039@jra3> Reply-To: Jeremy Allison References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, May 10, 2018 at 11:04:14AM -0500, Steve French via samba-technical wrote: > As with NFS, which ignores sync on directory handles, > fsync on a directory handle is a noop for CIFS/SMB3. > Do not return an error on it. It breaks some database > apps otherwise. Thanks for this. I now have an smbtorture test that shows we handle flush on directories incorrectly. Patch to follow. Jeremy. > -- > Thanks, > > Steve > From 6112a4967573f9a347f7abc02e80423851b73737 Mon Sep 17 00:00:00 2001 > From: Steve French > Date: Thu, 10 May 2018 10:59:37 -0500 > Subject: [PATCH] smb3: directory sync should not return an error > > As with NFS, which ignores sync on directory handles, > fsync on a directory handle is a noop for CIFS/SMB3. > Do not return an error on it. It breaks some database > apps otherwise. > > Signed-off-by: Steve French > CC: Stable > --- > fs/cifs/cifsfs.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c > index ed8e181927d6..8e41186d9923 100644 > --- a/fs/cifs/cifsfs.c > +++ b/fs/cifs/cifsfs.c > @@ -1049,6 +1049,18 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, > return rc; > } > > +/* > + * Directory operations under CIFS/SMB2/SMB3 are synchronous, so fsync() > + * is a dummy operation. > + */ > +int cifs_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync) > +{ > + cifs_dbg(FYI, "Sync directory - name: %pD datasync: 0x%x\n", > + file, datasync); > + > + return 0; > +} > + > static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, > struct file *dst_file, loff_t destoff, > size_t len, unsigned int flags) > @@ -1183,6 +1195,7 @@ const struct file_operations cifs_dir_ops = { > .copy_file_range = cifs_copy_file_range, > .clone_file_range = cifs_clone_file_range, > .llseek = generic_file_llseek, > + .fsync = cifs_dir_fsync, > }; > > static void > -- > 2.17.0 >