diff options
author | Steve French <sfrench@us.ibm.com> | 2005-10-05 15:23:19 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2005-10-05 15:23:19 -0400 |
commit | 6148a742b2bd76abfe0c1fc50dd747cb9f28cd6b (patch) | |
tree | 186396bf1e71e981e033e4b5becc2ab6c47fcfca /fs/cifs/inode.c | |
parent | 04c08816d693f010ce14b8f408c6228600053af0 (diff) |
CIFS: Create routine find_writable_file to reduce redundant code
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r-- | fs/cifs/inode.c | 56 |
1 files changed, 14 insertions, 42 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ca3af4eafcb2..49efdefcff7c 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -995,7 +995,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
995 | filemap_fdatawait(direntry->d_inode->i_mapping); | 995 | filemap_fdatawait(direntry->d_inode->i_mapping); |
996 | 996 | ||
997 | if (attrs->ia_valid & ATTR_SIZE) { | 997 | if (attrs->ia_valid & ATTR_SIZE) { |
998 | read_lock(&GlobalSMBSeslock); | ||
999 | /* To avoid spurious oplock breaks from server, in the case of | 998 | /* To avoid spurious oplock breaks from server, in the case of |
1000 | inodes that we already have open, avoid doing path based | 999 | inodes that we already have open, avoid doing path based |
1001 | setting of file size if we can do it by handle. | 1000 | setting of file size if we can do it by handle. |
@@ -1003,49 +1002,22 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1003 | when the local oplock break takes longer to flush | 1002 | when the local oplock break takes longer to flush |
1004 | writebehind data than the SMB timeout for the SetPathInfo | 1003 | writebehind data than the SMB timeout for the SetPathInfo |
1005 | request would allow */ | 1004 | request would allow */ |
1006 | list_for_each(tmp, &cifsInode->openFileList) { | 1005 | open_file = find_writable_file(cifsInode); |
1007 | open_file = list_entry(tmp, struct cifsFileInfo, | 1006 | if (open_file) { |
1008 | flist); | 1007 | __u16 nfid = open_file->netfid; |
1009 | /* We check if file is open for writing first */ | 1008 | __u32 npid = open_file->pid; |
1010 | if ((open_file->pfile) && | 1009 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, |
1011 | ((open_file->pfile->f_flags & O_RDWR) || | 1010 | nfid, npid, FALSE); |
1012 | (open_file->pfile->f_flags & O_WRONLY))) { | 1011 | cFYI(1,("SetFSize for attrs rc = %d", rc)); |
1013 | if (open_file->invalidHandle == FALSE) { | 1012 | if(rc == -EINVAL) { |
1014 | /* we found a valid, writeable network | 1013 | int bytes_written; |
1015 | file handle to use to try to set the | 1014 | rc = CIFSSMBWrite(xid, pTcon, |
1016 | file size */ | 1015 | nfid, 0, attrs->ia_size, |
1017 | __u16 nfid = open_file->netfid; | 1016 | &bytes_written, NULL, NULL, |
1018 | __u32 npid = open_file->pid; | 1017 | 1 /* 45 seconds */); |
1019 | read_unlock(&GlobalSMBSeslock); | 1018 | cFYI(1,("Wrt seteof rc %d", rc)); |
1020 | found = TRUE; | ||
1021 | rc = CIFSSMBSetFileSize(xid, pTcon, | ||
1022 | attrs->ia_size, nfid, npid, | ||
1023 | FALSE); | ||
1024 | cFYI(1, ("SetFileSize by handle " | ||
1025 | "(setattrs) rc = %d", rc)); | ||
1026 | /* Do not need reopen and retry on | ||
1027 | EAGAIN since we will retry by | ||
1028 | pathname below */ | ||
1029 | |||
1030 | /* now that we found one valid file | ||
1031 | handle no sense continuing to loop | ||
1032 | trying others, so break here */ | ||
1033 | if(rc == -EINVAL) { | ||
1034 | int bytes_written; | ||
1035 | rc = CIFSSMBWrite(xid, pTcon, | ||
1036 | nfid, 0, | ||
1037 | attrs->ia_size, | ||
1038 | &bytes_written, NULL, | ||
1039 | NULL, 1 /* 45 sec */); | ||
1040 | cFYI(1,("wrt seteof rc %d",rc)); | ||
1041 | } | ||
1042 | break; | ||
1043 | } | ||
1044 | } | 1019 | } |
1045 | } | 1020 | } |
1046 | if (found == FALSE) | ||
1047 | read_unlock(&GlobalSMBSeslock); | ||
1048 | |||
1049 | if (rc != 0) { | 1021 | if (rc != 0) { |
1050 | /* Set file size by pathname rather than by handle | 1022 | /* Set file size by pathname rather than by handle |
1051 | either because no valid, writeable file handle for | 1023 | either because no valid, writeable file handle for |