cifs: eliminate cifsInodeInfo->write_behind_rc (try #6)

write_behind_rc is redundant and just adds complexity to the code. What
we really want to do instead is to use mapping_set_error to reset the
flags on the mapping when we find a writeback error and can't report it
to userspace yet.

For cifs_flush and cifs_fsync, we shouldn't reset the flags since errors
returned there do get reported to userspace.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Suresh Jayaraman <sjayaraman@suse.de>
Reviewed-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
Jeff Layton 2010-10-22 14:52:29 -04:00 committed by Steve French
parent 6c0f6218ba
commit eb4b756b1e
4 changed files with 15 additions and 39 deletions

View File

@ -318,7 +318,6 @@ cifs_alloc_inode(struct super_block *sb)
return NULL; return NULL;
cifs_inode->cifsAttrs = 0x20; /* default */ cifs_inode->cifsAttrs = 0x20; /* default */
cifs_inode->time = 0; cifs_inode->time = 0;
cifs_inode->write_behind_rc = 0;
/* Until the file is open and we have gotten oplock /* Until the file is open and we have gotten oplock
info back from the server, can not assume caching of info back from the server, can not assume caching of
file data or metadata */ file data or metadata */

View File

@ -420,7 +420,6 @@ struct cifsInodeInfo {
struct list_head lockList; struct list_head lockList;
/* BB add in lists for dirty pages i.e. write caching info for oplock */ /* BB add in lists for dirty pages i.e. write caching info for oplock */
struct list_head openFileList; struct list_head openFileList;
int write_behind_rc;
__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
unsigned long time; /* jiffies of last update/check of inode */ unsigned long time; /* jiffies of last update/check of inode */
bool clientCanCacheRead:1; /* read oplock */ bool clientCanCacheRead:1; /* read oplock */

View File

@ -131,8 +131,7 @@ static inline int cifs_open_inode_helper(struct inode *inode,
/* BB no need to lock inode until after invalidate /* BB no need to lock inode until after invalidate
since namei code should already have it locked? */ since namei code should already have it locked? */
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc != 0) mapping_set_error(inode->i_mapping, rc);
pCifsInode->write_behind_rc = rc;
} }
cFYI(1, "invalidating remote inode since open detected it " cFYI(1, "invalidating remote inode since open detected it "
"changed"); "changed");
@ -606,8 +605,7 @@ reopen_success:
if (can_flush) { if (can_flush) {
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc != 0) mapping_set_error(inode->i_mapping, rc);
CIFS_I(inode)->write_behind_rc = rc;
pCifsInode->clientCanCacheAll = false; pCifsInode->clientCanCacheAll = false;
pCifsInode->clientCanCacheRead = false; pCifsInode->clientCanCacheRead = false;
@ -1489,12 +1487,7 @@ retry:
if (rc || bytes_written < bytes_to_write) { if (rc || bytes_written < bytes_to_write) {
cERROR(1, "Write2 ret %d, wrote %d", cERROR(1, "Write2 ret %d, wrote %d",
rc, bytes_written); rc, bytes_written);
/* BB what if continued retry is mapping_set_error(mapping, rc);
requested via mount flags? */
if (rc == -ENOSPC)
set_bit(AS_ENOSPC, &mapping->flags);
else
set_bit(AS_EIO, &mapping->flags);
} else { } else {
cifs_stats_bytes_written(tcon, bytes_written); cifs_stats_bytes_written(tcon, bytes_written);
} }
@ -1639,11 +1632,10 @@ int cifs_fsync(struct file *file, int datasync)
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc == 0) { if (rc == 0) {
rc = CIFS_I(inode)->write_behind_rc; struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
CIFS_I(inode)->write_behind_rc = 0;
tcon = tlink_tcon(smbfile->tlink); tcon = tlink_tcon(smbfile->tlink);
if (!rc && tcon && smbfile && if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
!(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
} }
@ -1688,14 +1680,8 @@ int cifs_flush(struct file *file, fl_owner_t id)
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
int rc = 0; int rc = 0;
if (file->f_mode & FMODE_WRITE) { if (file->f_mode & FMODE_WRITE)
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
/* reset wb rc if we were able to write out dirty pages */
if (!rc) {
rc = CIFS_I(inode)->write_behind_rc;
CIFS_I(inode)->write_behind_rc = 0;
}
}
cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc); cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
@ -2274,7 +2260,7 @@ void cifs_oplock_break(struct work_struct *work)
oplock_break); oplock_break);
struct inode *inode = cfile->dentry->d_inode; struct inode *inode = cfile->dentry->d_inode;
struct cifsInodeInfo *cinode = CIFS_I(inode); struct cifsInodeInfo *cinode = CIFS_I(inode);
int rc, waitrc = 0; int rc = 0;
if (inode && S_ISREG(inode->i_mode)) { if (inode && S_ISREG(inode->i_mode)) {
if (cinode->clientCanCacheRead) if (cinode->clientCanCacheRead)
@ -2283,13 +2269,10 @@ void cifs_oplock_break(struct work_struct *work)
break_lease(inode, O_WRONLY); break_lease(inode, O_WRONLY);
rc = filemap_fdatawrite(inode->i_mapping); rc = filemap_fdatawrite(inode->i_mapping);
if (cinode->clientCanCacheRead == 0) { if (cinode->clientCanCacheRead == 0) {
waitrc = filemap_fdatawait(inode->i_mapping); rc = filemap_fdatawait(inode->i_mapping);
mapping_set_error(inode->i_mapping, rc);
invalidate_remote_inode(inode); invalidate_remote_inode(inode);
} }
if (!rc)
rc = waitrc;
if (rc)
cinode->write_behind_rc = rc;
cFYI(1, "Oplock flush inode %p rc %d", inode, rc); cFYI(1, "Oplock flush inode %p rc %d", inode, rc);
} }

View File

@ -1682,8 +1682,7 @@ cifs_invalidate_mapping(struct inode *inode)
/* write back any cached data */ /* write back any cached data */
if (inode->i_mapping && inode->i_mapping->nrpages != 0) { if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc) mapping_set_error(inode->i_mapping, rc);
cifs_i->write_behind_rc = rc;
} }
invalidate_remote_inode(inode); invalidate_remote_inode(inode);
cifs_fscache_reset_inode_cookie(inode); cifs_fscache_reset_inode_cookie(inode);
@ -1943,10 +1942,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
* the flush returns error? * the flush returns error?
*/ */
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc != 0) { mapping_set_error(inode->i_mapping, rc);
cifsInode->write_behind_rc = rc; rc = 0;
rc = 0;
}
if (attrs->ia_valid & ATTR_SIZE) { if (attrs->ia_valid & ATTR_SIZE) {
rc = cifs_set_file_size(inode, attrs, xid, full_path); rc = cifs_set_file_size(inode, attrs, xid, full_path);
@ -2087,10 +2084,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
* the flush returns error? * the flush returns error?
*/ */
rc = filemap_write_and_wait(inode->i_mapping); rc = filemap_write_and_wait(inode->i_mapping);
if (rc != 0) { mapping_set_error(inode->i_mapping, rc);
cifsInode->write_behind_rc = rc; rc = 0;
rc = 0;
}
if (attrs->ia_valid & ATTR_SIZE) { if (attrs->ia_valid & ATTR_SIZE) {
rc = cifs_set_file_size(inode, attrs, xid, full_path); rc = cifs_set_file_size(inode, attrs, xid, full_path);