diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-10-22 14:52:29 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-10-24 20:19:00 -0400 |
commit | eb4b756b1e60b66e54932619088b645c712414a3 (patch) | |
tree | c2a10df2f33be6bd9a8b5491cc1815515dc59e84 /fs/cifs | |
parent | 6c0f6218ba04a5d6e61d0c55b68e6c4ef0736531 (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')
-rw-r--r-- | fs/cifs/cifsfs.c | 1 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 1 | ||||
-rw-r--r-- | fs/cifs/file.c | 37 | ||||
-rw-r--r-- | fs/cifs/inode.c | 15 |
4 files changed, 15 insertions, 39 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 34371637f210..e8b9523c9f39 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -318,7 +318,6 @@ cifs_alloc_inode(struct super_block *sb) | |||
318 | return NULL; | 318 | return NULL; |
319 | cifs_inode->cifsAttrs = 0x20; /* default */ | 319 | cifs_inode->cifsAttrs = 0x20; /* default */ |
320 | cifs_inode->time = 0; | 320 | cifs_inode->time = 0; |
321 | cifs_inode->write_behind_rc = 0; | ||
322 | /* Until the file is open and we have gotten oplock | 321 | /* Until the file is open and we have gotten oplock |
323 | info back from the server, can not assume caching of | 322 | info back from the server, can not assume caching of |
324 | file data or metadata */ | 323 | file data or metadata */ |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 7128c291cec8..ef5709b250e6 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -420,7 +420,6 @@ struct cifsInodeInfo { | |||
420 | struct list_head lockList; | 420 | struct list_head lockList; |
421 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ | 421 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ |
422 | struct list_head openFileList; | 422 | struct list_head openFileList; |
423 | int write_behind_rc; | ||
424 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ | 423 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ |
425 | unsigned long time; /* jiffies of last update/check of inode */ | 424 | unsigned long time; /* jiffies of last update/check of inode */ |
426 | bool clientCanCacheRead:1; /* read oplock */ | 425 | bool clientCanCacheRead:1; /* read oplock */ |
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 | ||
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 94979309698a..39869c3c3efb 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1682,8 +1682,7 @@ cifs_invalidate_mapping(struct inode *inode) | |||
1682 | /* write back any cached data */ | 1682 | /* write back any cached data */ |
1683 | if (inode->i_mapping && inode->i_mapping->nrpages != 0) { | 1683 | if (inode->i_mapping && inode->i_mapping->nrpages != 0) { |
1684 | rc = filemap_write_and_wait(inode->i_mapping); | 1684 | rc = filemap_write_and_wait(inode->i_mapping); |
1685 | if (rc) | 1685 | mapping_set_error(inode->i_mapping, rc); |
1686 | cifs_i->write_behind_rc = rc; | ||
1687 | } | 1686 | } |
1688 | invalidate_remote_inode(inode); | 1687 | invalidate_remote_inode(inode); |
1689 | cifs_fscache_reset_inode_cookie(inode); | 1688 | cifs_fscache_reset_inode_cookie(inode); |
@@ -1943,10 +1942,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) | |||
1943 | * the flush returns error? | 1942 | * the flush returns error? |
1944 | */ | 1943 | */ |
1945 | rc = filemap_write_and_wait(inode->i_mapping); | 1944 | rc = filemap_write_and_wait(inode->i_mapping); |
1946 | if (rc != 0) { | 1945 | mapping_set_error(inode->i_mapping, rc); |
1947 | cifsInode->write_behind_rc = rc; | 1946 | rc = 0; |
1948 | rc = 0; | ||
1949 | } | ||
1950 | 1947 | ||
1951 | if (attrs->ia_valid & ATTR_SIZE) { | 1948 | if (attrs->ia_valid & ATTR_SIZE) { |
1952 | rc = cifs_set_file_size(inode, attrs, xid, full_path); | 1949 | rc = cifs_set_file_size(inode, attrs, xid, full_path); |
@@ -2087,10 +2084,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) | |||
2087 | * the flush returns error? | 2084 | * the flush returns error? |
2088 | */ | 2085 | */ |
2089 | rc = filemap_write_and_wait(inode->i_mapping); | 2086 | rc = filemap_write_and_wait(inode->i_mapping); |
2090 | if (rc != 0) { | 2087 | mapping_set_error(inode->i_mapping, rc); |
2091 | cifsInode->write_behind_rc = rc; | 2088 | rc = 0; |
2092 | rc = 0; | ||
2093 | } | ||
2094 | 2089 | ||
2095 | if (attrs->ia_valid & ATTR_SIZE) { | 2090 | if (attrs->ia_valid & ATTR_SIZE) { |
2096 | rc = cifs_set_file_size(inode, attrs, xid, full_path); | 2091 | rc = cifs_set_file_size(inode, attrs, xid, full_path); |