CIFS: Simplify invalidate part (try #5)
Subsystems (2)
PATCH 1/1 CIFS: Simplify invalidate part (try #5)
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
--- fs/cifs/cifsfs.c | 33 +++++++++++----- fs/cifs/cifsfs.h | 4 +- fs/cifs/file.c | 16 ++++++-- fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 113 insertions(+), 57 deletions(-)
fs/cifs/cifsfs.c +23 -10
@@ -618,16 +618,29 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) {/* origin == SEEK_END => we must revalidate the cached file length */ if (origin ==SEEK_END ) { -int retval; - -/* some applications poll for the file length in this strange -way so we must seek to end on non-oplocked files by -setting the revalidate time to zero */ -CIFS_I (file->f_path.dentry->d_inode)->time =0 ; - - retval =cifs_revalidate_file (file); -if (retval <0 ) -return (loff_t )retval; +int rc; +struct inode *inode = file->f_path.dentry->d_inode; + +/* +* We need to be sure that all dirty pages are written and the +* server has the newest file length. +*/ +if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +mapping_set_error (inode->i_mapping, rc); +return rc; + } +/* +* Some applications poll for the file length in this strange +* way so we must seek to end on non-oplocked files by +* setting the revalidate time to zero. +*/ +CIFS_I (inode)->time =0 ; + + rc =cifs_revalidate_file_attr (file); +if (rc <0 ) +return (loff_t )rc; }return generic_file_llseek_unlocked (file, offset, origin); }
fs/cifs/cifsfs.h +3 -1
@@ -59,9 +59,11 @@ extern int cifs_mkdir(struct inode *, struct dentry *, int);extern int cifs_rmdir (struct inode *,struct dentry *);extern int cifs_rename (struct inode *,struct dentry *,struct inode *,struct dentry *); +extern int cifs_revalidate_file_attr (struct file *filp); +extern int cifs_revalidate_dentry_attr (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_invalidate_mapping (struct inode *inode);extern int cifs_getattr (struct vfsmount *,struct dentry *,struct kstat *);extern int cifs_setattr (struct dentry *,struct iattr *);
fs/cifs/file.c +12 -4
@@ -1534,8 +1534,13 @@ int cifs_strict_fsync(struct file *file, int datasync)cFYI (1 ,"Sync file - name: %s datasync: 0x%x" , file->f_path.dentry->d_name.name, datasync); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) { +cFYI (1 ,"rc: %d during invalidate phase" , rc); + rc =0 ;/* don't care about it in fsync */ + } + } tcon =tlink_tcon (smbfile->tlink);if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC ))
@@ -2002,8 +2007,11 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) xid =GetXid (); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) +return rc; + } rc =generic_file_mmap (file, vma);if (rc ==0 )
fs/cifs/inode.c +75 -42
190 lines not on this page · raw message
Signature · 1 line
1.7.1
A message that is not in the archive (sent off-list or not yet received): 1303565417-3653-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org
With this patch do you still measure a slight performance degradation (e.g. with dbench) and how much?
Quoted 311 lines · Pavel Shilovsky
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)fs/cifs/cifsfs.c +23
-10@@ -618,16 +618,29 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) { /* origin == SEEK_END => we must revalidate the cached file length */ if (origin == SEEK_END) { - int retval; - - /* some applications poll for the file length in this strange - way so we must seek to end on non-oplocked files by - setting the revalidate time to zero */ - CIFS_I(file->f_path.dentry->d_inode)->time = 0; - - retval = cifs_revalidate_file(file); - if (retval < 0) - return (loff_t)retval; + int rc; + struct inode *inode = file->f_path.dentry->d_inode; + + /* + * We need to be sure that all dirty pages are written and the + * server has the newest file length. + */ + if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages != 0) { + rc = filemap_fdatawait(inode->i_mapping); + mapping_set_error(inode->i_mapping, rc); + return rc; + } + /* + * Some applications poll for the file length in this strange + * way so we must seek to end on non-oplocked files by + * setting the revalidate time to zero. + */ + CIFS_I(inode)->time = 0; + + rc = cifs_revalidate_file_attr(file); + if (rc < 0) + return (loff_t)rc; } return generic_file_llseek_unlocked(file, offset, origin); }fs/cifs/cifsfs.h +3
-1@@ -59,9 +59,11 @@ extern int cifs_mkdir(struct inode *, struct dentry *, int); extern int cifs_rmdir(struct inode *, struct dentry *); extern int cifs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); +extern int cifs_revalidate_file_attr (struct file *filp); +extern int cifs_revalidate_dentry_attr (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_invalidate_mapping (struct inode *inode); extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int cifs_setattr(struct dentry *, struct iattr *);fs/cifs/file.c +12
-4@@ -1534,8 +1534,13 @@ int cifs_strict_fsync(struct file *file, int datasync) cFYI(1, "Sync file - name: %s datasync: 0x%x", file->f_path.dentry->d_name.name, datasync); - if (!CIFS_I(inode)->clientCanCacheRead) - cifs_invalidate_mapping(inode); + if (!CIFS_I(inode)->clientCanCacheRead) { + rc = cifs_invalidate_mapping(inode); + if (rc) { + cFYI(1, "rc: %d during invalidate phase", rc); + rc = 0; /* don't care about it in fsync */ + } + } tcon = tlink_tcon(smbfile->tlink); if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))@@ -2002,8 +2007,11 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) xid = GetXid(); - if (!CIFS_I(inode)->clientCanCacheRead) - cifs_invalidate_mapping(inode); + if (!CIFS_I(inode)->clientCanCacheRead) { + rc = cifs_invalidate_mapping(inode); + if (rc) + return rc; + } rc = generic_file_mmap(file, vma); if (rc == 0)fs/cifs/inode.c +5
-7@@ -1683,18 +1683,15 @@ cifs_inode_needs_reval(struct inode *inode) /** Zap the cache. Called when invalid_mapping flag is set. */ -void +int cifs_invalidate_mapping(struct inode *inode) { - int rc; + int rc = 0; struct cifsInodeInfo *cifs_i = CIFS_I(inode); cifs_i->invalid_mapping = false; if (inode->i_mapping && inode->i_mapping->nrpages != 0) { - /* write back any cached data */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); rc = invalidate_inode_pages2(inode->i_mapping); if (rc) { cERROR(1, "%s: could not invalidate inode %p", __func__,@@ -1704,56 +1701,52 @@ cifs_invalidate_mapping(struct inode *inode) } cifs_fscache_reset_inode_cookie(inode); + return rc; } -int cifs_revalidate_file (struct file *filp) +int cifs_revalidate_file_attr (struct file *filp) { int rc = 0; struct inode *inode = filp->f_path.dentry->d_inode; struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data; if (!cifs_inode_needs_reval(inode)) - goto check_inval; + return rc; if (tlink_tcon(cfile->tlink)->unix_ext) rc = cifs_get_file_info_unix(filp);else
rc =cifs_get_file_info(filp);fs/cifs/inode.c +0
-4-check_inval: - if (CIFS_I(inode)->invalid_mapping) - cifs_invalidate_mapping(inode); -return rc;
}fs/cifs/inode.c +1
-2-/* revalidate a dentry's inode attributes */ -int cifs_revalidate_dentry (struct dentry *dentry) +int cifs_revalidate_dentry_attr (struct dentry *dentry){
int xid;
int rc = 0;
- char*full_path= NULL;
struct inode *inode =dentry->d_inode;
structsuper_block*sb =dentry->d_sb;
+ char*full_path= NULL;if (inode == NULL)
return-ENOENT;- xid =
GetXid();
-
if (!cifs_inode_needs_reval(inode))
- gotocheck_inval;
+ return rc;
+
+ xid =GetXid();/* can not safely grab the rename sem here if rename calls revalidate since that would deadlock */
full_path =build_path_from_dentry(dentry);
if (full_path== NULL) {
rc =-ENOMEM;
- gotocheck_inval;
+ goto out;
}- cFYI(1, "Revalidate: %s inode 0x%p count %d dentry: 0x%p
d_time%ld "
- "jiffies %ld",full_path, inode,inode->i_count.counter,
+ cFYI(1, "Update attributes: %s inode 0x%p count %d dentry: 0x%pd_time"
+ "%ld jiffies %ld",full_path, inode,inode->i_count.counter, dentry,dentry->d_time, jiffies);if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
fs/cifs/inode.c +62
-23@@ -1762,41 +1755,81 @@ int cifs_revalidate_dentry(struct dentry *dentry) rc = cifs_get_inode_info(&inode, full_path, NULL, sb, xid, NULL); -check_inval: - if (CIFS_I(inode)->invalid_mapping) - cifs_invalidate_mapping(inode); - +out: kfree(full_path); FreeXid(xid); return rc; } +int cifs_revalidate_file (struct file *filp) +{ + int rc; + struct inode *inode = filp->f_path.dentry->d_inode; + + rc = cifs_revalidate_file_attr(filp); + if (rc) + return rc; + + if (CIFS_I(inode)->invalid_mapping) + rc = cifs_invalidate_mapping(inode); + return rc; +} + +/* revalidate a dentry's inode attributes */ +int cifs_revalidate_dentry (struct dentry *dentry) +{ + int rc; + struct inode *inode = dentry->d_inode; + + rc = cifs_revalidate_dentry_attr(dentry); + if (rc) + return rc; + + if (CIFS_I(inode)->invalid_mapping) + rc = cifs_invalidate_mapping(inode); + return rc; +} + int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb); struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); - int err = cifs_revalidate_dentry(dentry); + struct inode *inode = dentry->d_inode; + int rc; - if (!err) { - generic_fillattr(dentry->d_inode, stat); - stat->blksize = CIFS_MAX_MSGSIZE; - stat->ino = CIFS_I(dentry->d_inode)->uniqueid; + /* + * We need to be sure that all dirty pages are written and the server + * has actual ctime, mtime and file length. + */ + if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages != 0) { + rc = filemap_fdatawait(inode->i_mapping); + mapping_set_error(inode->i_mapping, rc); + return rc; + } - /* - * If on a multiuser mount without unix extensions, and the - * admin hasn't overridden them, set the ownership to the - * fsuid/fsgid of the current process. - */ - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) && - !tcon->unix_ext) { - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) - stat->uid = current_fsuid(); - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) - stat->gid = current_fsgid(); - } + rc = cifs_revalidate_dentry_attr(dentry); + if (rc) + return rc; + + generic_fillattr(inode, stat); + stat->blksize = CIFS_MAX_MSGSIZE; + stat->ino = CIFS_I(inode)->uniqueid; + + /* + * If on a multiuser mount without unix extensions, and the admin hasn't + * overridden them, set the ownership to the fsuid/fsgid of the current + * process. + */ + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) && + !tcon->unix_ext) { + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) + stat->uid = current_fsuid(); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) + stat->gid = current_fsgid(); } - return err; + return rc; } static int cifs_truncate_page(struct address_space *mapping, loff_t from) --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Thanks, Steve
2011/4/23 Steve French <[email protected]>:
Quoted 3 lines
With this patch do you still measure a slight performance degradation (e.g. with dbench) and how much?
I tested it several times and didn't notice any difference between this version and try #4 (without filemap_fdatawait calls) in dbench (dbench -D dir 1). But, anyway, this patch brings ~5% performance itself (in comparison with current state of for-next branch).
Signature · 2 lines
Best regards, Pavel Shilovsky.
A message that is not in the archive (sent off-list or not yet received): BANLkTinoBtt0UfXOHt2SamjX__30YeagsQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 9 lines · Pavel Shilovsky
2011/4/23 Steve French <[email protected]>:
Quoted 3 lines
With this patch do you still measure a slight performance degradation (e.g. with dbench) and how much?
I tested it several times and didn't notice any difference between this version and try #4 (without
filemap_fdatawaitcalls) in dbench (dbench -D dir 1). But, anyway, this patch brings ~5% performance itself (in comparison with current state of for-next branch).
Can you clarify what you mean by ~5%? Did it fix a perf problem?
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): BANLkTinqaNMQGGSqQ5v4o14degrTBpL1Zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
2011/4/24 Steve French <[email protected]>:
Quoted 6 lines · Pavel Shilovsky
Quoted 5 lines
2011/4/23 Steve French <[email protected]>:
Quoted 3 lines
With this patch do you still measure a slight performance degradation (e.g. with dbench) and how much?
Quoted 7 lines
Quoted 4 lines
I tested it several times and didn't notice any difference between this version and try #4 (without
filemap_fdatawaitcalls) in dbench (dbench -D dir 1). But, anyway, this patch brings ~5% performance itself (in comparison with current state of for-next branch).Can you clarify what you mean by ~5%? Did it fix a perf problem?
Sorry for wasn't clear. I mean when I tested it more carefully (with several runs) I got the following results against Windows 7 on LAN (throughput):
1) for-next + try #4 and for-next + try #5 ~ 2.59 MB/sec;
2) for-next ~ 2.48 MB/sec.
So, this patch increases performance by 5%.
Signature · 2 lines
Best regards, Pavel Shilovsky.
Jeff Layton
Reviewed-byQuoted 293 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/cifsfs.c | 33 +++++++++++----- fs/cifs/cifsfs.h | 4 +- fs/cifs/file.c | 16 ++++++-- fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 113 insertions(+), 57 deletions(-)fs/cifs/cifsfs.c +23
-10@@ -618,16 +618,29 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) {/* origin == SEEK_END => we must revalidate the cached file length */ if (origin ==SEEK_END ) { -int retval; - -/* some applications poll for the file length in this strange -way so we must seek to end on non-oplocked files by -setting the revalidate time to zero */ -CIFS_I (file->f_path.dentry->d_inode)->time =0 ; - - retval =cifs_revalidate_file (file); -if (retval <0 ) -return (loff_t )retval; +int rc; +struct inode *inode = file->f_path.dentry->d_inode; + +/* +* We need to be sure that all dirty pages are written and the +* server has the newest file length. +*/ +if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +mapping_set_error (inode->i_mapping, rc); +return rc; + } +/* +* Some applications poll for the file length in this strange +* way so we must seek to end on non-oplocked files by +* setting the revalidate time to zero. +*/ +CIFS_I (inode)->time =0 ; + + rc =cifs_revalidate_file_attr (file); +if (rc <0 ) +return (loff_t )rc; }return generic_file_llseek_unlocked (file, offset, origin); }fs/cifs/cifsfs.h +3
-1@@ -59,9 +59,11 @@ extern int cifs_mkdir(struct inode *, struct dentry *, int);extern int cifs_rmdir (struct inode *,struct dentry *);extern int cifs_rename (struct inode *,struct dentry *,struct inode *,struct dentry *); +extern int cifs_revalidate_file_attr (struct file *filp); +extern int cifs_revalidate_dentry_attr (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_invalidate_mapping (struct inode *inode);extern int cifs_getattr (struct vfsmount *,struct dentry *,struct kstat *);extern int cifs_setattr (struct dentry *,struct iattr *);fs/cifs/file.c +12
-4@@ -1534,8 +1534,13 @@ int cifs_strict_fsync(struct file *file, int datasync)cFYI (1 ,"Sync file - name: %s datasync: 0x%x" , file->f_path.dentry->d_name.name, datasync); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) { +cFYI (1 ,"rc: %d during invalidate phase" , rc); + rc =0 ;/* don't care about it in fsync */ + } + } tcon =tlink_tcon (smbfile->tlink);if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC ))@@ -2002,8 +2007,11 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) xid =GetXid (); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) +return rc; + } rc =generic_file_mmap (file, vma);if (rc ==0 )fs/cifs/inode.c +70
-41@@ -1683,18 +1683,15 @@ cifs_inode_needs_reval(struct inode *inode)/* * Zap the cache. Called when invalid_mapping flag is set. */ -void +int cifs_invalidate_mapping (struct inode *inode) { -int rc; +int rc =0 ;struct cifsInodeInfo *cifs_i =CIFS_I (inode); cifs_i->invalid_mapping = false;if (inode->i_mapping && inode->i_mapping->nrpages !=0 ) { -/* write back any cached data */ - rc =filemap_write_and_wait (inode->i_mapping); -mapping_set_error (inode->i_mapping, rc); rc =invalidate_inode_pages2 (inode->i_mapping);if (rc) { cERROR(1, "%s: could not invalidate inode %p", __func__,@@ -1704,56 +1701,52 @@ cifs_invalidate_mapping(struct inode *inode) }cifs_fscache_reset_inode_cookie (inode); +return rc; } -int cifs_revalidate_file (struct file *filp) +int cifs_revalidate_file_attr (struct file *filp) {int rc =0 ;struct inode *inode = filp->f_path.dentry->d_inode;struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;if (!cifs_inode_needs_reval (inode)) - goto check_inval; +return rc;if (tlink_tcon (cfile->tlink)->unix_ext) rc =cifs_get_file_info_unix (filp);else rc =cifs_get_file_info (filp); -check_inval: -if (CIFS_I (inode)->invalid_mapping) -cifs_invalidate_mapping (inode); -return rc; } -/* revalidate a dentry's inode attributes */ -int cifs_revalidate_dentry (struct dentry *dentry) +int cifs_revalidate_dentry_attr (struct dentry *dentry) {int xid;int rc =0 ; -char *full_path =NULL ;struct inode *inode = dentry->d_inode;struct super_block *sb = dentry->d_sb; +char *full_path =NULL ;if (inode ==NULL )return -ENOENT ; - xid =GetXid (); -if (!cifs_inode_needs_reval (inode)) - goto check_inval; +return rc; + + xid =GetXid ();/* can not safely grab the rename sem here if rename calls revalidate since that would deadlock */ full_path =build_path_from_dentry (dentry);if (full_path ==NULL ) { rc = -ENOMEM ; - goto check_inval; + goto out; } -cFYI (1 ,"Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld " -"jiffies %ld" , full_path, inode, inode->i_count.counter, +cFYI (1 ,"Update attributes: %s inode 0x%p count %d dentry: 0x%p d_time " +"%ld jiffies %ld" , full_path, inode, inode->i_count.counter, dentry, dentry->d_time, jiffies);if (cifs_sb_master_tcon (CIFS_SB (sb))->unix_ext)@@ -1762,41 +1755,81 @@ int cifs_revalidate_dentry(struct dentry *dentry) rc =cifs_get_inode_info (&inode, full_path,NULL , sb, xid,NULL ); -check_inval: -if (CIFS_I (inode)->invalid_mapping) -cifs_invalidate_mapping (inode); - +out:kfree (full_path);FreeXid (xid);return rc; } +int cifs_revalidate_file (struct file *filp) +{ +int rc; +struct inode *inode = filp->f_path.dentry->d_inode; + + rc =cifs_revalidate_file_attr (filp); +if (rc) +return rc; + +if (CIFS_I (inode)->invalid_mapping) + rc =cifs_invalidate_mapping (inode); +return rc; +} + +/* revalidate a dentry's inode attributes */ +int cifs_revalidate_dentry (struct dentry *dentry) +{ +int rc; +struct inode *inode = dentry->d_inode; + + rc =cifs_revalidate_dentry_attr (dentry); +if (rc) +return rc; + +if (CIFS_I (inode)->invalid_mapping) + rc =cifs_invalidate_mapping (inode); +return rc; +} +int cifs_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) {struct cifs_sb_info *cifs_sb =CIFS_SB (dentry->d_sb);struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb); -int err =cifs_revalidate_dentry (dentry); +struct inode *inode = dentry->d_inode; +int rc; -if (!err) { -generic_fillattr (dentry->d_inode, stat); - stat->blksize =CIFS_MAX_MSGSIZE ; - stat->ino =CIFS_I (dentry->d_inode)->uniqueid; +/* +* We need to be sure that all dirty pages are written and the server +* has actual ctime, mtime and file length. +*/ +if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +mapping_set_error (inode->i_mapping, rc); +return rc; + } -/* -* If on a multiuser mount without unix extensions, and the -* admin hasn't overridden them, set the ownership to the -* fsuid/fsgid of the current process. -*/ -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER ) && - !tcon->unix_ext) { -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID )) - stat->uid =current_fsuid (); -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_GID )) - stat->gid =current_fsgid (); - } + rc =cifs_revalidate_dentry_attr (dentry); +if (rc) +return rc; + +generic_fillattr (inode, stat); + stat->blksize =CIFS_MAX_MSGSIZE ; + stat->ino =CIFS_I (inode)->uniqueid; + +/* +* If on a multiuser mount without unix extensions, and the admin hasn't +* overridden them, set the ownership to the fsuid/fsgid of the current +* process. +*/ +if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER ) && + !tcon->unix_ext) {
fs/cifs/inode.c int cifs_revalidate_dentry(struct dentry *dentry) · line 1835
Quoted 10 lines
fs/cifs/inode.c +5
-1+if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID )) + stat->uid =current_fsuid (); +if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_GID )) + stat->gid =current_fsgid (); } -return err; +return rc; }static int cifs_truncate_page (struct address_space *mapping,loff_t from)
Looks good to me.
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/cifsfs.c | 33 +++++++++++----- fs/cifs/cifsfs.h | 4 +- fs/cifs/file.c | 16 ++++++-- fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 113 insertions(+), 57 deletions(-)
This patch is causing a regression in tests5:
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576
basic tests failed
Pavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20110519140132.32850e2c-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org
Quoted 15 lines · On Thu, 19 May 2011 14:01:32 -0400 Jeff Layton…
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/cifsfs.c | 33 +++++++++++----- fs/cifs/cifsfs.h | 4 +- fs/cifs/file.c | 16 ++++++-- fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 113 insertions(+), 57 deletions(-)
Quoted 2 lines
This patch is causing a regression in tests5:
Sorry, that should be "connectathon basic test5"...
Quoted 9 lines
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576basic tests failed
Pavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
Signature · 1 line
Jeff Layton <[email protected]>
2011/5/19 Jeff Layton <[email protected]>:
Quoted 15 lines
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)
Quoted 7 lines
This patch is causing a regression in tests5:
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576 basic tests failedPavel, can you track this down?
Yes, thanks! I will look it this tomorrow.
Quoted 11 lines
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
--
Jeff Layton <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky.
Pavel Shilovsky
Reviewed-by Jeff Layton2011/5/19 Jeff Layton <[email protected]>:
Quoted 17 lines
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)This patch is causing a regression in tests5:
Quoted 9 lines
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576 basic tests failedPavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
I figured it out.
Steve, I attach two diffs: 1) diff for this version of the patch and
2) new fixed version of the whole patch - you can use either one that is more comfortable to you.
Signature · 2 lines
Best regards, Pavel Shilovsky.
fs/cifs/cifsfs.c +4 -2
@@ -617,8 +617,10 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && inode->i_mapping->nrpages !=0 ) { rc =filemap_fdatawait (inode->i_mapping); -mapping_set_error (inode->i_mapping, rc); -return rc; +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } }/* * Some applications poll for the file length in this strange
fs/cifs/inode.c +4 -2
@@ -1805,8 +1805,10 @@ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry,if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && inode->i_mapping->nrpages !=0 ) { rc =filemap_fdatawait (inode->i_mapping); -mapping_set_error (inode->i_mapping, rc); -return rc; +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } } rc =cifs_revalidate_dentry_attr (dentry);
From d48c10e8001243c458b87812ad3f608ab7dd3095 Mon Sep 17 00:00:00 2001
From: Pavel Shilovsky <[email protected]>
Date: Thu, 7 Apr 2011 18:18:11 +0400
Subject: [PATCH] CIFS: Simplify invalidate part (try #6)
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
--- fs/cifs/cifsfs.c | 35 +++++++++++----- fs/cifs/cifsfs.h | 4 +- fs/cifs/file.c | 16 +++++-- fs/cifs/inode.c | 119 +++++++++++++++++++++++++++++++++++------------------- 4 files changed, 117 insertions(+), 57 deletions(-)
fs/cifs/cifsfs.c +25 -10
@@ -618,16 +618,31 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) {/* origin == SEEK_END => we must revalidate the cached file length */ if (origin ==SEEK_END ) { -int retval; - -/* some applications poll for the file length in this strange -way so we must seek to end on non-oplocked files by -setting the revalidate time to zero */ -CIFS_I (file->f_path.dentry->d_inode)->time =0 ; - - retval =cifs_revalidate_file (file); -if (retval <0 ) -return (loff_t )retval; +int rc; +struct inode *inode = file->f_path.dentry->d_inode; + +/* +* We need to be sure that all dirty pages are written and the +* server has the newest file length. +*/ +if (!CIFS_I (inode)->clientCanCacheRead && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } + } +/* +* Some applications poll for the file length in this strange +* way so we must seek to end on non-oplocked files by +* setting the revalidate time to zero. +*/ +CIFS_I (inode)->time =0 ; + + rc =cifs_revalidate_file_attr (file); +if (rc <0 ) +return (loff_t )rc; }return generic_file_llseek_unlocked (file, offset, origin); }
fs/cifs/cifsfs.h +3 -1
@@ -59,9 +59,11 @@ extern int cifs_mkdir(struct inode *, struct dentry *, int);extern int cifs_rmdir (struct inode *,struct dentry *);extern int cifs_rename (struct inode *,struct dentry *,struct inode *,struct dentry *); +extern int cifs_revalidate_file_attr (struct file *filp); +extern int cifs_revalidate_dentry_attr (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_invalidate_mapping (struct inode *inode);extern int cifs_getattr (struct vfsmount *,struct dentry *,struct kstat *);extern int cifs_setattr (struct dentry *,struct iattr *);
fs/cifs/file.c +12 -4
@@ -1445,8 +1445,13 @@ int cifs_strict_fsync(struct file *file, int datasync)cFYI (1 ,"Sync file - name: %s datasync: 0x%x" , file->f_path.dentry->d_name.name, datasync); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) { +cFYI (1 ,"rc: %d during invalidate phase" , rc); + rc =0 ;/* don't care about it in fsync */ + } + } tcon =tlink_tcon (smbfile->tlink);if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC ))
@@ -1903,8 +1908,11 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) xid =GetXid (); -if (!CIFS_I (inode)->clientCanCacheRead) -cifs_invalidate_mapping (inode); +if (!CIFS_I (inode)->clientCanCacheRead) { + rc =cifs_invalidate_mapping (inode); +if (rc) +return rc; + } rc =generic_file_mmap (file, vma);if (rc ==0 )
fs/cifs/inode.c +77 -42
192 lines not on this page · raw message
Signature · 1 line
1.7.1
A message that is not in the archive (sent off-list or not yet received): BANLkTinsqwMoFzP+9+qX+W+Gr+LGae0Rdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 28 lines · On Fri, 20 May 2011 13:00:53 +0400 Pavel Shilovsky…
2011/5/19 Jeff Layton <[email protected]>:
Quoted 17 lines
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)This patch is causing a regression in tests5:
Quoted 9 lines
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576 basic tests failedPavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
Quoted 6 lines
I figured it out.
Steve, I attach two diffs: 1) diff for this version of the patch and
2) new fixed version of the whole patch - you can use either one that is more comfortable to you.
Confirmed -- the patch seems to fix the issue. With that, all the connectathon tests seem to now pass.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20110520073053.6b113a4a-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
merged
Quoted 44 lines · Jeff Layton
Quoted 28 lines · On Fri, 20 May 2011 13:00:53 +0400 Pavel Shilovsky…
2011/5/19 Jeff Layton <[email protected]>:
Quoted 17 lines
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)This patch is causing a regression in tests5:
Quoted 9 lines
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576 basic tests failedPavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
Quoted 6 lines
I figured it out.
Steve, I attach two diffs: 1) diff for this version of the patch and
2) new fixed version of the whole patch - you can use either one that is more comfortable to you.Confirmed -- the patch seems to fix the issue. With that, all the connectathon tests seem to now pass.
--
Jeff Layton <[email protected]>
Signature · 3 lines
Thanks, Steve
The fix makes sense, but it reminded me - would allowing "mapping_set_error" when rc is zero reset/clear a saved error - and would we want that (ie getattr or llseek able to flush a page which we failed writing earlier could clear the saved error if we allowed mapping_set_error on rc == 0)?
Quoted 38 lines · Pavel Shilovsky
2011/5/19 Jeff Layton <[email protected]>:
Quoted 17 lines
Quoted 11 lines · On Sat, 23 Apr 2011 17:30:17 +0400 Pavel Shilovsky…
Simplify many places when we call cifs_revalidate/invalidate to make it do what it exactly needs.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsfs.c | 33 +++++++++++-----
fs/cifs/cifsfs.h | 4 +-
fs/cifs/file.c | 16 ++++++--
fs/cifs/inode.c | 117 ++++++++++++++++++++++++++++++++++-------------------4 files changed, 113 insertions(+), 57 deletions(-)This patch is causing a regression in tests5:
Quoted 9 lines
./test5: read and write
./test5: (/mnt/salusa/rawhide.test) 'bigfile' has size -2130066000, should be 1048576 basic tests failedPavel, can you track this down?
Steve, in the meantime I suggest that this patch not be pushed when the merge window opens.
I figured it out.
Steve, I attach two diffs: 1) diff for this version of the patch and
2) new fixed version of the whole patch - you can use either one that is more comfortable to you.--
Best regards,
Pavel Shilovsky.
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): BANLkTi=6jvvugqCTjYTx6FredDswkFZccw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 6 lines · Steve French
The fix makes sense, but it reminded me - would allowing "
mapping_set_error" when rc is zero reset/clear a saved error - and would we want that (ie getattr or llseek able to flush a page which we failed writing earlier could clear the saved error if we allowedmapping_set_erroron rc == 0)?
Nevermind - mapping_set_error bails out when rc is 0.
Signature · 3 lines
Thanks, Steve