aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/inode.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-18 19:20:31 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:29 -0400
commitd143341815bdc7c45d5289a3ab5743c838332518 (patch)
tree2e94221eb03a569e07fa4118b7d68c507f66efb4 /fs/cifs/inode.c
parent568798cc6211553e2494a6876fa19d064c822e79 (diff)
CIFS: Move set_file_size to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r--fs/cifs/inode.c106
1 files changed, 56 insertions, 50 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2f3235f08c3f..85e1b0a405a8 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1883,7 +1883,8 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1883 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1883 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1884 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1884 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1885 struct tcon_link *tlink = NULL; 1885 struct tcon_link *tlink = NULL;
1886 struct cifs_tcon *pTcon = NULL; 1886 struct cifs_tcon *tcon = NULL;
1887 struct TCP_Server_Info *server;
1887 struct cifs_io_parms io_parms; 1888 struct cifs_io_parms io_parms;
1888 1889
1889 /* 1890 /*
@@ -1897,19 +1898,21 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1897 */ 1898 */
1898 open_file = find_writable_file(cifsInode, true); 1899 open_file = find_writable_file(cifsInode, true);
1899 if (open_file) { 1900 if (open_file) {
1900 __u16 nfid = open_file->fid.netfid; 1901 tcon = tlink_tcon(open_file->tlink);
1901 __u32 npid = open_file->pid; 1902 server = tcon->ses->server;
1902 pTcon = tlink_tcon(open_file->tlink); 1903 if (server->ops->set_file_size)
1903 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid, 1904 rc = server->ops->set_file_size(xid, tcon, open_file,
1904 npid, false); 1905 attrs->ia_size, false);
1906 else
1907 rc = -ENOSYS;
1905 cifsFileInfo_put(open_file); 1908 cifsFileInfo_put(open_file);
1906 cFYI(1, "SetFSize for attrs rc = %d", rc); 1909 cFYI(1, "SetFSize for attrs rc = %d", rc);
1907 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1910 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1908 unsigned int bytes_written; 1911 unsigned int bytes_written;
1909 1912
1910 io_parms.netfid = nfid; 1913 io_parms.netfid = open_file->fid.netfid;
1911 io_parms.pid = npid; 1914 io_parms.pid = open_file->pid;
1912 io_parms.tcon = pTcon; 1915 io_parms.tcon = tcon;
1913 io_parms.offset = 0; 1916 io_parms.offset = 0;
1914 io_parms.length = attrs->ia_size; 1917 io_parms.length = attrs->ia_size;
1915 rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, 1918 rc = CIFSSMBWrite(xid, &io_parms, &bytes_written,
@@ -1919,52 +1922,55 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1919 } else 1922 } else
1920 rc = -EINVAL; 1923 rc = -EINVAL;
1921 1924
1922 if (rc != 0) { 1925 if (!rc)
1923 if (pTcon == NULL) { 1926 goto set_size_out;
1924 tlink = cifs_sb_tlink(cifs_sb);
1925 if (IS_ERR(tlink))
1926 return PTR_ERR(tlink);
1927 pTcon = tlink_tcon(tlink);
1928 }
1929 1927
1930 /* Set file size by pathname rather than by handle 1928 if (tcon == NULL) {
1931 either because no valid, writeable file handle for 1929 tlink = cifs_sb_tlink(cifs_sb);
1932 it was found or because there was an error setting 1930 if (IS_ERR(tlink))
1933 it by handle */ 1931 return PTR_ERR(tlink);
1934 rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, 1932 tcon = tlink_tcon(tlink);
1935 false, cifs_sb->local_nls, 1933 server = tcon->ses->server;
1934 }
1935
1936 /*
1937 * Set file size by pathname rather than by handle either because no
1938 * valid, writeable file handle for it was found or because there was
1939 * an error setting it by handle.
1940 */
1941 if (server->ops->set_path_size)
1942 rc = server->ops->set_path_size(xid, tcon, full_path,
1943 attrs->ia_size, cifs_sb, false);
1944 else
1945 rc = -ENOSYS;
1946 cFYI(1, "SetEOF by path (setattrs) rc = %d", rc);
1947 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1948 __u16 netfid;
1949 int oplock = 0;
1950
1951 rc = SMBLegacyOpen(xid, tcon, full_path, FILE_OPEN,
1952 GENERIC_WRITE, CREATE_NOT_DIR, &netfid,
1953 &oplock, NULL, cifs_sb->local_nls,
1936 cifs_sb->mnt_cifs_flags & 1954 cifs_sb->mnt_cifs_flags &
1937 CIFS_MOUNT_MAP_SPECIAL_CHR); 1955 CIFS_MOUNT_MAP_SPECIAL_CHR);
1938 cFYI(1, "SetEOF by path (setattrs) rc = %d", rc); 1956 if (rc == 0) {
1939 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1957 unsigned int bytes_written;
1940 __u16 netfid; 1958
1941 int oplock = 0; 1959 io_parms.netfid = netfid;
1942 1960 io_parms.pid = current->tgid;
1943 rc = SMBLegacyOpen(xid, pTcon, full_path, 1961 io_parms.tcon = tcon;
1944 FILE_OPEN, GENERIC_WRITE, 1962 io_parms.offset = 0;
1945 CREATE_NOT_DIR, &netfid, &oplock, NULL, 1963 io_parms.length = attrs->ia_size;
1946 cifs_sb->local_nls, 1964 rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, NULL,
1947 cifs_sb->mnt_cifs_flags & 1965 NULL, 1);
1948 CIFS_MOUNT_MAP_SPECIAL_CHR); 1966 cFYI(1, "wrt seteof rc %d", rc);
1949 if (rc == 0) { 1967 CIFSSMBClose(xid, tcon, netfid);
1950 unsigned int bytes_written;
1951
1952 io_parms.netfid = netfid;
1953 io_parms.pid = current->tgid;
1954 io_parms.tcon = pTcon;
1955 io_parms.offset = 0;
1956 io_parms.length = attrs->ia_size;
1957 rc = CIFSSMBWrite(xid, &io_parms,
1958 &bytes_written,
1959 NULL, NULL, 1);
1960 cFYI(1, "wrt seteof rc %d", rc);
1961 CIFSSMBClose(xid, pTcon, netfid);
1962 }
1963 } 1968 }
1964 if (tlink)
1965 cifs_put_tlink(tlink);
1966 } 1969 }
1970 if (tlink)
1971 cifs_put_tlink(tlink);
1967 1972
1973set_size_out:
1968 if (rc == 0) { 1974 if (rc == 0) {
1969 cifsInode->server_eof = attrs->ia_size; 1975 cifsInode->server_eof = attrs->ia_size;
1970 cifs_setsize(inode, attrs->ia_size); 1976 cifs_setsize(inode, attrs->ia_size);