aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-10-22 14:52:29 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-24 20:19:00 -0400
commiteb4b756b1e60b66e54932619088b645c712414a3 (patch)
treec2a10df2f33be6bd9a8b5491cc1815515dc59e84 /fs/cifs/file.c
parent6c0f6218ba04a5d6e61d0c55b68e6c4ef0736531 (diff)
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>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 128e07b85d6c..ad47820655d9 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -131,8 +131,7 @@ static inline int cifs_open_inode_helper(struct inode *inode,
131 /* BB no need to lock inode until after invalidate 131 /* BB no need to lock inode until after invalidate
132 since namei code should already have it locked? */ 132 since namei code should already have it locked? */
133 rc = filemap_write_and_wait(inode->i_mapping); 133 rc = filemap_write_and_wait(inode->i_mapping);
134 if (rc != 0) 134 mapping_set_error(inode->i_mapping, rc);
135 pCifsInode->write_behind_rc = rc;
136 } 135 }
137 cFYI(1, "invalidating remote inode since open detected it " 136 cFYI(1, "invalidating remote inode since open detected it "
138 "changed"); 137 "changed");
@@ -606,8 +605,7 @@ reopen_success:
606 605
607 if (can_flush) { 606 if (can_flush) {
608 rc = filemap_write_and_wait(inode->i_mapping); 607 rc = filemap_write_and_wait(inode->i_mapping);
609 if (rc != 0) 608 mapping_set_error(inode->i_mapping, rc);
610 CIFS_I(inode)->write_behind_rc = rc;
611 609
612 pCifsInode->clientCanCacheAll = false; 610 pCifsInode->clientCanCacheAll = false;
613 pCifsInode->clientCanCacheRead = false; 611 pCifsInode->clientCanCacheRead = false;
@@ -1489,12 +1487,7 @@ retry:
1489 if (rc || bytes_written < bytes_to_write) { 1487 if (rc || bytes_written < bytes_to_write) {
1490 cERROR(1, "Write2 ret %d, wrote %d", 1488 cERROR(1, "Write2 ret %d, wrote %d",
1491 rc, bytes_written); 1489 rc, bytes_written);
1492 /* BB what if continued retry is 1490 mapping_set_error(mapping, rc);
1493 requested via mount flags? */
1494 if (rc == -ENOSPC)
1495 set_bit(AS_ENOSPC, &mapping->flags);
1496 else
1497 set_bit(AS_EIO, &mapping->flags);
1498 } else { 1491 } else {
1499 cifs_stats_bytes_written(tcon, bytes_written); 1492 cifs_stats_bytes_written(tcon, bytes_written);
1500 } 1493 }
@@ -1639,11 +1632,10 @@ int cifs_fsync(struct file *file, int datasync)
1639 1632
1640 rc = filemap_write_and_wait(inode->i_mapping); 1633 rc = filemap_write_and_wait(inode->i_mapping);
1641 if (rc == 0) { 1634 if (rc == 0) {
1642 rc = CIFS_I(inode)->write_behind_rc; 1635 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1643 CIFS_I(inode)->write_behind_rc = 0; 1636
1644 tcon = tlink_tcon(smbfile->tlink); 1637 tcon = tlink_tcon(smbfile->tlink);
1645 if (!rc && tcon && smbfile && 1638 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1646 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1647 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1639 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
1648 } 1640 }
1649 1641
@@ -1688,14 +1680,8 @@ int cifs_flush(struct file *file, fl_owner_t id)
1688 struct inode *inode = file->f_path.dentry->d_inode; 1680 struct inode *inode = file->f_path.dentry->d_inode;
1689 int rc = 0; 1681 int rc = 0;
1690 1682
1691 if (file->f_mode & FMODE_WRITE) { 1683 if (file->f_mode & FMODE_WRITE)
1692 rc = filemap_write_and_wait(inode->i_mapping); 1684 rc = filemap_write_and_wait(inode->i_mapping);
1693 /* reset wb rc if we were able to write out dirty pages */
1694 if (!rc) {
1695 rc = CIFS_I(inode)->write_behind_rc;
1696 CIFS_I(inode)->write_behind_rc = 0;
1697 }
1698 }
1699 1685
1700 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc); 1686 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
1701 1687
@@ -2274,7 +2260,7 @@ void cifs_oplock_break(struct work_struct *work)
2274 oplock_break); 2260 oplock_break);
2275 struct inode *inode = cfile->dentry->d_inode; 2261 struct inode *inode = cfile->dentry->d_inode;
2276 struct cifsInodeInfo *cinode = CIFS_I(inode); 2262 struct cifsInodeInfo *cinode = CIFS_I(inode);
2277 int rc, waitrc = 0; 2263 int rc = 0;
2278 2264
2279 if (inode && S_ISREG(inode->i_mode)) { 2265 if (inode && S_ISREG(inode->i_mode)) {
2280 if (cinode->clientCanCacheRead) 2266 if (cinode->clientCanCacheRead)
@@ -2283,13 +2269,10 @@ void cifs_oplock_break(struct work_struct *work)
2283 break_lease(inode, O_WRONLY); 2269 break_lease(inode, O_WRONLY);
2284 rc = filemap_fdatawrite(inode->i_mapping); 2270 rc = filemap_fdatawrite(inode->i_mapping);
2285 if (cinode->clientCanCacheRead == 0) { 2271 if (cinode->clientCanCacheRead == 0) {
2286 waitrc = filemap_fdatawait(inode->i_mapping); 2272 rc = filemap_fdatawait(inode->i_mapping);
2273 mapping_set_error(inode->i_mapping, rc);
2287 invalidate_remote_inode(inode); 2274 invalidate_remote_inode(inode);
2288 } 2275 }
2289 if (!rc)
2290 rc = waitrc;
2291 if (rc)
2292 cinode->write_behind_rc = rc;
2293 cFYI(1, "Oplock flush inode %p rc %d", inode, rc); 2276 cFYI(1, "Oplock flush inode %p rc %d", inode, rc);
2294 } 2277 }
2295 2278