* [PATCH 2/6] CIFS: Make read call work with strict cache mode (try #3)
@ 2010-11-29 13:36 Pavel Shilovsky
[not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Pavel Shilovsky @ 2010-11-29 13:36 UTC (permalink / raw)
To: linux-cifs-u79uwXL29TY76Z2rM5mHXA
Add cifs_file_aio_read where we read from the cache if we have at least
Level II oplock - otherwise read from the server.
Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
fs/cifs/cifsfs.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9c37897..431c46e 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -568,6 +568,44 @@ cifs_do_mount(struct file_system_type *fs_type,
return dget(sb->s_root);
}
+static ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
+ unsigned long nr_segs, loff_t pos)
+{
+ struct inode *inode;
+ struct cifs_sb_info *cifs_sb;
+ ssize_t read = 0, retval;
+ unsigned long i;
+
+ inode = iocb->ki_filp->f_path.dentry->d_inode;
+ cifs_sb = CIFS_SB(iocb->ki_filp->f_path.dentry->d_sb);
+
+ if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) == 0 ||
+ CIFS_I(inode)->clientCanCacheRead)
+ return generic_file_aio_read(iocb, iov, nr_segs, pos);
+
+ /* In strict cache mode we need to read from the server all the time
+ * if we don't have level II oplock because the server can delay mtime
+ * change - so we can't make a decision about inode invalidating.
+ * And we can also fail with pagereading if there are mandatory locks
+ * on pages affected by this read but not on the region from pos to
+ * pos+len-1. */
+
+ for (i = 0; i < nr_segs; i++) {
+ retval = cifs_user_read(iocb->ki_filp, iov[i].iov_base,
+ iov[i].iov_len, &pos);
+ if (retval < 0) {
+ read = read ? read : retval;
+ break;
+ }
+
+ read += retval;
+ }
+
+ iocb->ki_pos = pos;
+
+ return read;
+}
+
static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
@@ -690,7 +728,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
const struct file_operations cifs_file_ops = {
.read = do_sync_read,
.write = do_sync_write,
- .aio_read = generic_file_aio_read,
+ .aio_read = cifs_file_aio_read,
.aio_write = cifs_file_aio_write,
.open = cifs_open,
.release = cifs_close,
@@ -727,7 +765,7 @@ const struct file_operations cifs_file_direct_ops = {
const struct file_operations cifs_file_nobrl_ops = {
.read = do_sync_read,
.write = do_sync_write,
- .aio_read = generic_file_aio_read,
+ .aio_read = cifs_file_aio_read,
.aio_write = cifs_file_aio_write,
.open = cifs_open,
.release = cifs_close,
--
1.7.3.2
^ permalink raw reply related [flat|nested] 10+ messages in thread[parent not found: <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH 3/6] CIFS: Make write call work with strict cache mode (try #3) [not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-11-29 13:36 ` Pavel Shilovsky [not found] ` <1291037804-4000-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-11-29 13:36 ` [PATCH 4/6] CIFS: Make cifs_fsync " Pavel Shilovsky ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Pavel Shilovsky @ 2010-11-29 13:36 UTC (permalink / raw) To: linux-cifs-u79uwXL29TY76Z2rM5mHXA On strict cache mode if we don't have Exclusive oplock we write a data to the server through cifs_user_write. Also set inode invalid_mapping flag if we have written anything to the server. Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- fs/cifs/cifsfs.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 431c46e..0732538 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -609,12 +609,51 @@ static ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov, static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { - struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; - ssize_t written; + struct inode *inode; + struct cifs_sb_info *cifs_sb; + ssize_t written = 0, retval; + unsigned long i; + + inode = iocb->ki_filp->f_path.dentry->d_inode; + + if (CIFS_I(inode)->clientCanCacheAll) + return generic_file_aio_write(iocb, iov, nr_segs, pos); + + cifs_sb = CIFS_SB(iocb->ki_filp->f_path.dentry->d_sb); + + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) == 0) { + int rc; + + written = generic_file_aio_write(iocb, iov, nr_segs, pos); + + rc = filemap_fdatawrite(inode->i_mapping); + if (rc) + cFYI(1, "cifs_file_aio_write: %d rc on %p inode", + rc, inode); + return written; + } + + /* In strict cache mode we need to write the data to the server exactly + * from the pos to pos+len-1 rather than flush all affected pages + * because it may cause a error with mandatory locks on these pages but + * not on the region from pos to ppos+len-1. */ + + for (i = 0; i < nr_segs; i++) { + retval = cifs_user_write(iocb->ki_filp, iov[i].iov_base, + iov[i].iov_len, &pos); + if (retval < 0) { + written = written ? written : retval; + break; + } + + written += retval; + } + + iocb->ki_pos = pos; + + if (written > 0) + CIFS_I(inode)->invalid_mapping = true; - written = generic_file_aio_write(iocb, iov, nr_segs, pos); - if (!CIFS_I(inode)->clientCanCacheAll) - filemap_fdatawrite(inode->i_mapping); return written; } -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1291037804-4000-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 3/6] CIFS: Make write call work with strict cache mode (try #3) [not found] ` <1291037804-4000-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-11-30 7:56 ` Pavel Shilovsky 0 siblings, 0 replies; 10+ messages in thread From: Pavel Shilovsky @ 2010-11-30 7:56 UTC (permalink / raw) To: linux-cifs-u79uwXL29TY76Z2rM5mHXA 2010/11/29 Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > On strict cache mode if we don't have Exclusive oplock we write a data to > the server through cifs_user_write. Also set inode invalid_mapping flag if > we have written anything to the server. > > Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > fs/cifs/cifsfs.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- > 1 files changed, 44 insertions(+), 5 deletions(-) > > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c > index 431c46e..0732538 100644 > --- a/fs/cifs/cifsfs.c > +++ b/fs/cifs/cifsfs.c > @@ -609,12 +609,51 @@ static ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov, > static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, > unsigned long nr_segs, loff_t pos) > { > - struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; > - ssize_t written; > + struct inode *inode; > + struct cifs_sb_info *cifs_sb; > + ssize_t written = 0, retval; > + unsigned long i; > + > + inode = iocb->ki_filp->f_path.dentry->d_inode; > + > + if (CIFS_I(inode)->clientCanCacheAll) > + return generic_file_aio_write(iocb, iov, nr_segs, pos); > + > + cifs_sb = CIFS_SB(iocb->ki_filp->f_path.dentry->d_sb); > + > + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) == 0) { > + int rc; > + > + written = generic_file_aio_write(iocb, iov, nr_segs, pos); > + > + rc = filemap_fdatawrite(inode->i_mapping); > + if (rc) > + cFYI(1, "cifs_file_aio_write: %d rc on %p inode", > + rc, inode); > + return written; > + } > + > + /* In strict cache mode we need to write the data to the server exactly > + * from the pos to pos+len-1 rather than flush all affected pages > + * because it may cause a error with mandatory locks on these pages but > + * not on the region from pos to ppos+len-1. */ > + > + for (i = 0; i < nr_segs; i++) { > + retval = cifs_user_write(iocb->ki_filp, iov[i].iov_base, > + iov[i].iov_len, &pos); > + if (retval < 0) { > + written = written ? written : retval; > + break; > + } > + > + written += retval; > + } > + > + iocb->ki_pos = pos; > + > + if (written > 0) > + CIFS_I(inode)->invalid_mapping = true; > > - written = generic_file_aio_write(iocb, iov, nr_segs, pos); > - if (!CIFS_I(inode)->clientCanCacheAll) > - filemap_fdatawrite(inode->i_mapping); > return written; > } > > -- > 1.7.3.2 > > See correct one in try #4. -- Best regards, Pavel Shilovsky. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/6] CIFS: Make cifs_fsync work with strict cache mode (try #3) [not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-11-29 13:36 ` [PATCH 3/6] CIFS: Make write " Pavel Shilovsky @ 2010-11-29 13:36 ` Pavel Shilovsky [not found] ` <1291037804-4000-3-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-11-29 13:36 ` [PATCH 5/6] CIFS: Make cifs_file_map " Pavel Shilovsky 2010-11-30 7:43 ` [PATCH 2/6] CIFS: Make read call " Pavel Shilovsky 3 siblings, 1 reply; 10+ messages in thread From: Pavel Shilovsky @ 2010-11-29 13:36 UTC (permalink / raw) To: linux-cifs-u79uwXL29TY76Z2rM5mHXA Remove filemap_write_and_wait call because it is previously called from vfs_fsync_range and invalidate inode if we don't have at least Level II oplock and strcit cache mode switched on. Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- fs/cifs/cifsfs.h | 1 + fs/cifs/file.c | 14 +++++++------- fs/cifs/inode.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 897b2b2..b8d783c 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -61,6 +61,7 @@ extern int cifs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); extern int cifs_revalidate_file(struct file *filp); extern int cifs_revalidate_dentry(struct dentry *); +extern void cifs_invalidate_mapping(struct inode *inode); extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int cifs_setattr(struct dentry *, struct iattr *); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f853bf0..d216879 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1595,20 +1595,20 @@ int cifs_fsync(struct file *file, int datasync) struct cifsTconInfo *tcon; struct cifsFileInfo *smbfile = file->private_data; struct inode *inode = file->f_path.dentry->d_inode; + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); xid = GetXid(); cFYI(1, "Sync file - name: %s datasync: 0x%x", file->f_path.dentry->d_name.name, datasync); - rc = filemap_write_and_wait(inode->i_mapping); - if (rc == 0) { - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + if (!CIFS_I(inode)->clientCanCacheRead && + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)) + cifs_invalidate_mapping(inode); - tcon = tlink_tcon(smbfile->tlink); - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) - rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); - } + tcon = tlink_tcon(smbfile->tlink); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) + rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); FreeXid(xid); return rc; diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ff7d299..f90a40a 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1671,7 +1671,7 @@ cifs_inode_needs_reval(struct inode *inode) } /* check invalid_mapping flag and zap the cache if it's set */ -static void +void cifs_invalidate_mapping(struct inode *inode) { int rc; -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1291037804-4000-3-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 4/6] CIFS: Make cifs_fsync work with strict cache mode (try #3) [not found] ` <1291037804-4000-3-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-12-07 12:52 ` Jeff Layton 0 siblings, 0 replies; 10+ messages in thread From: Jeff Layton @ 2010-12-07 12:52 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA On Mon, 29 Nov 2010 16:36:43 +0300 Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Remove filemap_write_and_wait call because it is previously called from > vfs_fsync_range and invalidate inode if we don't have at least Level II > oplock and strcit cache mode switched on. > > Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > fs/cifs/cifsfs.h | 1 + > fs/cifs/file.c | 14 +++++++------- > fs/cifs/inode.c | 2 +- > 3 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h > index 897b2b2..b8d783c 100644 > --- a/fs/cifs/cifsfs.h > +++ b/fs/cifs/cifsfs.h > @@ -61,6 +61,7 @@ extern int cifs_rename(struct inode *, struct dentry *, struct inode *, > struct dentry *); > extern int cifs_revalidate_file(struct file *filp); > extern int cifs_revalidate_dentry(struct dentry *); > +extern void cifs_invalidate_mapping(struct inode *inode); > extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); > extern int cifs_setattr(struct dentry *, struct iattr *); > > diff --git a/fs/cifs/file.c b/fs/cifs/file.c > index f853bf0..d216879 100644 > --- a/fs/cifs/file.c > +++ b/fs/cifs/file.c > @@ -1595,20 +1595,20 @@ int cifs_fsync(struct file *file, int datasync) > struct cifsTconInfo *tcon; > struct cifsFileInfo *smbfile = file->private_data; > struct inode *inode = file->f_path.dentry->d_inode; > + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); > > xid = GetXid(); > > cFYI(1, "Sync file - name: %s datasync: 0x%x", > file->f_path.dentry->d_name.name, datasync); > > - rc = filemap_write_and_wait(inode->i_mapping); > - if (rc == 0) { > - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); > + if (!CIFS_I(inode)->clientCanCacheRead && > + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)) > + cifs_invalidate_mapping(inode); > > - tcon = tlink_tcon(smbfile->tlink); > - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) > - rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); > - } > + tcon = tlink_tcon(smbfile->tlink); > + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) > + rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); > > FreeXid(xid); > return rc; > diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c > index ff7d299..f90a40a 100644 > --- a/fs/cifs/inode.c > +++ b/fs/cifs/inode.c > @@ -1671,7 +1671,7 @@ cifs_inode_needs_reval(struct inode *inode) > } > > /* check invalid_mapping flag and zap the cache if it's set */ > -static void > +void > cifs_invalidate_mapping(struct inode *inode) > { > int rc; Looks reasonable, but I'll withhold the reviewed-by until the previous patches are fixed. -- Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/6] CIFS: Make cifs_file_map work with strict cache mode (try #3) [not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-11-29 13:36 ` [PATCH 3/6] CIFS: Make write " Pavel Shilovsky 2010-11-29 13:36 ` [PATCH 4/6] CIFS: Make cifs_fsync " Pavel Shilovsky @ 2010-11-29 13:36 ` Pavel Shilovsky [not found] ` <1291037804-4000-4-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2010-11-30 7:43 ` [PATCH 2/6] CIFS: Make read call " Pavel Shilovsky 3 siblings, 1 reply; 10+ messages in thread From: Pavel Shilovsky @ 2010-11-29 13:36 UTC (permalink / raw) To: linux-cifs-u79uwXL29TY76Z2rM5mHXA Invalidate inode if we don't have at least Level II oplock and strict cache mode switched on. Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- fs/cifs/file.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d216879..e9f2fae 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1812,14 +1812,24 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) { int rc, xid; + struct inode *inode = file->f_path.dentry->d_inode; + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); xid = GetXid(); - rc = cifs_revalidate_file(file); - if (rc) { - cFYI(1, "Validation prior to mmap failed, error=%d", rc); - FreeXid(xid); - return rc; + + if (!CIFS_I(inode)->clientCanCacheRead && + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)) + cifs_invalidate_mapping(inode); + else { + rc = cifs_revalidate_file(file); + if (rc) { + cFYI(1, "Validation prior to mmap failed, error=%d", + rc); + FreeXid(xid); + return rc; + } } + rc = generic_file_mmap(file, vma); FreeXid(xid); return rc; -- 1.7.3.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1291037804-4000-4-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 5/6] CIFS: Make cifs_file_map work with strict cache mode (try #3) [not found] ` <1291037804-4000-4-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2010-12-07 12:56 ` Jeff Layton [not found] ` <20101207075635.6f9c1c5f-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Jeff Layton @ 2010-12-07 12:56 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA On Mon, 29 Nov 2010 16:36:44 +0300 Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Invalidate inode if we don't have at least Level II oplock and strict > cache mode switched on. > > Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > fs/cifs/file.c | 20 +++++++++++++++----- > 1 files changed, 15 insertions(+), 5 deletions(-) > > diff --git a/fs/cifs/file.c b/fs/cifs/file.c > index d216879..e9f2fae 100644 > --- a/fs/cifs/file.c > +++ b/fs/cifs/file.c > @@ -1812,14 +1812,24 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, > int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) > { > int rc, xid; > + struct inode *inode = file->f_path.dentry->d_inode; > + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); > > xid = GetXid(); > - rc = cifs_revalidate_file(file); > - if (rc) { > - cFYI(1, "Validation prior to mmap failed, error=%d", rc); > - FreeXid(xid); > - return rc; > + > + if (!CIFS_I(inode)->clientCanCacheRead && > + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)) > + cifs_invalidate_mapping(inode); > + else { > + rc = cifs_revalidate_file(file); > + if (rc) { > + cFYI(1, "Validation prior to mmap failed, error=%d", > + rc); > + FreeXid(xid); > + return rc; > + } > } > + > rc = generic_file_mmap(file, vma); > FreeXid(xid); > return rc; Looks reasonable, though all of this special-casing sure is gross... Might it be better to have a set of cifs_strict_file/inode_ops and use those rather than all of these if/else conditions? -- Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20101207075635.6f9c1c5f-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>]
* Re: [PATCH 5/6] CIFS: Make cifs_file_map work with strict cache mode (try #3) [not found] ` <20101207075635.6f9c1c5f-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org> @ 2010-12-08 20:53 ` Pavel Shilovsky [not found] ` <AANLkTineJVVgK6aihGBLWJfEnEOuz67CcHncwBUpdvt0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Pavel Shilovsky @ 2010-12-08 20:53 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA 2010/12/7 Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > Looks reasonable, though all of this special-casing sure is gross... > > Might it be better to have a set of cifs_strict_file/inode_ops and use > those rather than all of these if/else conditions? > Good idea. So, do you mean to split all these aio_read, aio_write, fsync and mmap into strict and non-strict calls as we have in direct i/o case? -- Best regards, Pavel Shilovsky. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <AANLkTineJVVgK6aihGBLWJfEnEOuz67CcHncwBUpdvt0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 5/6] CIFS: Make cifs_file_map work with strict cache mode (try #3) [not found] ` <AANLkTineJVVgK6aihGBLWJfEnEOuz67CcHncwBUpdvt0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2010-12-08 20:59 ` Jeff Layton 0 siblings, 0 replies; 10+ messages in thread From: Jeff Layton @ 2010-12-08 20:59 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA On Wed, 8 Dec 2010 23:53:12 +0300 Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > 2010/12/7 Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>: > > Looks reasonable, though all of this special-casing sure is gross... > > > > Might it be better to have a set of cifs_strict_file/inode_ops and use > > those rather than all of these if/else conditions? > > > > Good idea. So, do you mean to split all these aio_read, aio_write, > fsync and mmap into strict and non-strict calls as we have in direct > i/o case? > Right. Once a mount is declared "strictcache" it won't ever change, so you might as well set the ops appropriately. -- Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/6] CIFS: Make read call work with strict cache mode (try #3) [not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ` (2 preceding siblings ...) 2010-11-29 13:36 ` [PATCH 5/6] CIFS: Make cifs_file_map " Pavel Shilovsky @ 2010-11-30 7:43 ` Pavel Shilovsky 3 siblings, 0 replies; 10+ messages in thread From: Pavel Shilovsky @ 2010-11-30 7:43 UTC (permalink / raw) To: linux-cifs-u79uwXL29TY76Z2rM5mHXA 2010/11/29 Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > Add cifs_file_aio_read where we read from the cache if we have at least > Level II oplock - otherwise read from the server. > > Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > fs/cifs/cifsfs.c | 42 ++++++++++++++++++++++++++++++++++++++++-- > 1 files changed, 40 insertions(+), 2 deletions(-) > > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c > index 9c37897..431c46e 100644 > --- a/fs/cifs/cifsfs.c > +++ b/fs/cifs/cifsfs.c > @@ -568,6 +568,44 @@ cifs_do_mount(struct file_system_type *fs_type, > return dget(sb->s_root); > } > > +static ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov, > + unsigned long nr_segs, loff_t pos) > +{ > + struct inode *inode; > + struct cifs_sb_info *cifs_sb; > + ssize_t read = 0, retval; > + unsigned long i; > + > + inode = iocb->ki_filp->f_path.dentry->d_inode; > + cifs_sb = CIFS_SB(iocb->ki_filp->f_path.dentry->d_sb); > + > + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) == 0 || > + CIFS_I(inode)->clientCanCacheRead) > + return generic_file_aio_read(iocb, iov, nr_segs, pos); > + > + /* In strict cache mode we need to read from the server all the time > + * if we don't have level II oplock because the server can delay mtime > + * change - so we can't make a decision about inode invalidating. > + * And we can also fail with pagereading if there are mandatory locks > + * on pages affected by this read but not on the region from pos to > + * pos+len-1. */ > + > + for (i = 0; i < nr_segs; i++) { > + retval = cifs_user_read(iocb->ki_filp, iov[i].iov_base, > + iov[i].iov_len, &pos); > + if (retval < 0) { > + read = read ? read : retval; > + break; > + } > + > + read += retval; > + } > + > + iocb->ki_pos = pos; > + > + return read; > +} > + > static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, > unsigned long nr_segs, loff_t pos) > { > @@ -690,7 +728,7 @@ const struct inode_operations cifs_symlink_inode_ops = { > const struct file_operations cifs_file_ops = { > .read = do_sync_read, > .write = do_sync_write, > - .aio_read = generic_file_aio_read, > + .aio_read = cifs_file_aio_read, > .aio_write = cifs_file_aio_write, > .open = cifs_open, > .release = cifs_close, > @@ -727,7 +765,7 @@ const struct file_operations cifs_file_direct_ops = { > const struct file_operations cifs_file_nobrl_ops = { > .read = do_sync_read, > .write = do_sync_write, > - .aio_read = generic_file_aio_read, > + .aio_read = cifs_file_aio_read, > .aio_write = cifs_file_aio_write, > .open = cifs_open, > .release = cifs_close, > -- > 1.7.3.2 > > Just found out that comment style don't match CodingStyle again. Let's drop with version. The same for write patch. -- Best regards, Pavel Shilovsky. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-12-08 20:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-29 13:36 [PATCH 2/6] CIFS: Make read call work with strict cache mode (try #3) Pavel Shilovsky
[not found] ` <1291037804-4000-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-11-29 13:36 ` [PATCH 3/6] CIFS: Make write " Pavel Shilovsky
[not found] ` <1291037804-4000-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-11-30 7:56 ` Pavel Shilovsky
2010-11-29 13:36 ` [PATCH 4/6] CIFS: Make cifs_fsync " Pavel Shilovsky
[not found] ` <1291037804-4000-3-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-12-07 12:52 ` Jeff Layton
2010-11-29 13:36 ` [PATCH 5/6] CIFS: Make cifs_file_map " Pavel Shilovsky
[not found] ` <1291037804-4000-4-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-12-07 12:56 ` Jeff Layton
[not found] ` <20101207075635.6f9c1c5f-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2010-12-08 20:53 ` Pavel Shilovsky
[not found] ` <AANLkTineJVVgK6aihGBLWJfEnEOuz67CcHncwBUpdvt0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-12-08 20:59 ` Jeff Layton
2010-11-30 7:43 ` [PATCH 2/6] CIFS: Make read call " Pavel Shilovsky
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox