aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-18 19:20:26 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:26 -0400
commit4b4de76e35518fc0c636f628abca8c1b19ad6689 (patch)
tree18b27673849d55235c216f0cbb811e1aa4b87ae9 /fs/cifs/file.c
parentcbe6f439f5762c7fb4d2dd9293f5fdbfc4cd68f8 (diff)
CIFS: Replace netfid with cifs_fid struct in cifsFileInfo
This is help us to extend the code for future protocols that can use another fid mechanism (as SMB2 that has it divided into two parts: persistent and violatile). Also rename variables and refactor the code around the changes. Reviewed-by: Jeff Layton <jlayton@samba.org> Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 71e9ad9f5961..712f2a4d0d49 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -247,39 +247,39 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
247{ 247{
248 struct dentry *dentry = file->f_path.dentry; 248 struct dentry *dentry = file->f_path.dentry;
249 struct inode *inode = dentry->d_inode; 249 struct inode *inode = dentry->d_inode;
250 struct cifsInodeInfo *pCifsInode = CIFS_I(inode); 250 struct cifsInodeInfo *cinode = CIFS_I(inode);
251 struct cifsFileInfo *pCifsFile; 251 struct cifsFileInfo *cfile;
252 252
253 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); 253 cfile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
254 if (pCifsFile == NULL) 254 if (cfile == NULL)
255 return pCifsFile; 255 return cfile;
256 256
257 pCifsFile->count = 1; 257 cfile->count = 1;
258 pCifsFile->netfid = fileHandle; 258 cfile->fid.netfid = fileHandle;
259 pCifsFile->pid = current->tgid; 259 cfile->pid = current->tgid;
260 pCifsFile->uid = current_fsuid(); 260 cfile->uid = current_fsuid();
261 pCifsFile->dentry = dget(dentry); 261 cfile->dentry = dget(dentry);
262 pCifsFile->f_flags = file->f_flags; 262 cfile->f_flags = file->f_flags;
263 pCifsFile->invalidHandle = false; 263 cfile->invalidHandle = false;
264 pCifsFile->tlink = cifs_get_tlink(tlink); 264 cfile->tlink = cifs_get_tlink(tlink);
265 mutex_init(&pCifsFile->fh_mutex); 265 mutex_init(&cfile->fh_mutex);
266 INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break); 266 INIT_WORK(&cfile->oplock_break, cifs_oplock_break);
267 INIT_LIST_HEAD(&pCifsFile->llist); 267 INIT_LIST_HEAD(&cfile->llist);
268 268
269 spin_lock(&cifs_file_list_lock); 269 spin_lock(&cifs_file_list_lock);
270 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList)); 270 list_add(&cfile->tlist, &(tlink_tcon(tlink)->openFileList));
271 /* if readable file instance put first in list*/ 271 /* if readable file instance put first in list*/
272 if (file->f_mode & FMODE_READ) 272 if (file->f_mode & FMODE_READ)
273 list_add(&pCifsFile->flist, &pCifsInode->openFileList); 273 list_add(&cfile->flist, &cinode->openFileList);
274 else 274 else
275 list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList); 275 list_add_tail(&cfile->flist, &cinode->openFileList);
276 spin_unlock(&cifs_file_list_lock); 276 spin_unlock(&cifs_file_list_lock);
277 277
278 cifs_set_oplock_level(pCifsInode, oplock); 278 cifs_set_oplock_level(cinode, oplock);
279 pCifsInode->can_cache_brlcks = pCifsInode->clientCanCacheAll; 279 cinode->can_cache_brlcks = cinode->clientCanCacheAll;
280 280
281 file->private_data = pCifsFile; 281 file->private_data = cfile;
282 return pCifsFile; 282 return cfile;
283} 283}
284 284
285static void cifs_del_lock_waiters(struct cifsLockInfo *lock); 285static void cifs_del_lock_waiters(struct cifsLockInfo *lock);
@@ -336,7 +336,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
336 unsigned int xid; 336 unsigned int xid;
337 int rc; 337 int rc;
338 xid = get_xid(); 338 xid = get_xid();
339 rc = CIFSSMBClose(xid, tcon, cifs_file->netfid); 339 rc = CIFSSMBClose(xid, tcon, cifs_file->fid.netfid);
340 free_xid(xid); 340 free_xid(xid);
341 } 341 }
342 342
@@ -561,7 +561,7 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
561 } 561 }
562 562
563reopen_success: 563reopen_success:
564 pCifsFile->netfid = netfid; 564 pCifsFile->fid.netfid = netfid;
565 pCifsFile->invalidHandle = false; 565 pCifsFile->invalidHandle = false;
566 mutex_unlock(&pCifsFile->fh_mutex); 566 mutex_unlock(&pCifsFile->fh_mutex);
567 pCifsInode = CIFS_I(inode); 567 pCifsInode = CIFS_I(inode);
@@ -609,39 +609,37 @@ int cifs_closedir(struct inode *inode, struct file *file)
609{ 609{
610 int rc = 0; 610 int rc = 0;
611 unsigned int xid; 611 unsigned int xid;
612 struct cifsFileInfo *pCFileStruct = file->private_data; 612 struct cifsFileInfo *cfile = file->private_data;
613 char *ptmp; 613 char *tmp;
614 614
615 cFYI(1, "Closedir inode = 0x%p", inode); 615 cFYI(1, "Closedir inode = 0x%p", inode);
616 616
617 xid = get_xid(); 617 xid = get_xid();
618 618
619 if (pCFileStruct) { 619 if (cfile) {
620 struct cifs_tcon *pTcon = tlink_tcon(pCFileStruct->tlink); 620 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
621 621
622 cFYI(1, "Freeing private data in close dir"); 622 cFYI(1, "Freeing private data in close dir");
623 spin_lock(&cifs_file_list_lock); 623 spin_lock(&cifs_file_list_lock);
624 if (!pCFileStruct->srch_inf.endOfSearch && 624 if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) {
625 !pCFileStruct->invalidHandle) { 625 cfile->invalidHandle = true;
626 pCFileStruct->invalidHandle = true;
627 spin_unlock(&cifs_file_list_lock); 626 spin_unlock(&cifs_file_list_lock);
628 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 627 rc = CIFSFindClose(xid, tcon, cfile->fid.netfid);
629 cFYI(1, "Closing uncompleted readdir with rc %d", 628 cFYI(1, "Closing uncompleted readdir with rc %d", rc);
630 rc);
631 /* not much we can do if it fails anyway, ignore rc */ 629 /* not much we can do if it fails anyway, ignore rc */
632 rc = 0; 630 rc = 0;
633 } else 631 } else
634 spin_unlock(&cifs_file_list_lock); 632 spin_unlock(&cifs_file_list_lock);
635 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start; 633 tmp = cfile->srch_inf.ntwrk_buf_start;
636 if (ptmp) { 634 if (tmp) {
637 cFYI(1, "closedir free smb buf in srch struct"); 635 cFYI(1, "closedir free smb buf in srch struct");
638 pCFileStruct->srch_inf.ntwrk_buf_start = NULL; 636 cfile->srch_inf.ntwrk_buf_start = NULL;
639 if (pCFileStruct->srch_inf.smallBuf) 637 if (cfile->srch_inf.smallBuf)
640 cifs_small_buf_release(ptmp); 638 cifs_small_buf_release(tmp);
641 else 639 else
642 cifs_buf_release(ptmp); 640 cifs_buf_release(tmp);
643 } 641 }
644 cifs_put_tlink(pCFileStruct->tlink); 642 cifs_put_tlink(cfile->tlink);
645 kfree(file->private_data); 643 kfree(file->private_data);
646 file->private_data = NULL; 644 file->private_data = NULL;
647 } 645 }
@@ -932,7 +930,8 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
932 cur->OffsetLow = cpu_to_le32((u32)li->offset); 930 cur->OffsetLow = cpu_to_le32((u32)li->offset);
933 cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32)); 931 cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32));
934 if (++num == max_num) { 932 if (++num == max_num) {
935 stored_rc = cifs_lockv(xid, tcon, cfile->netfid, 933 stored_rc = cifs_lockv(xid, tcon,
934 cfile->fid.netfid,
936 (__u8)li->type, 0, num, 935 (__u8)li->type, 0, num,
937 buf); 936 buf);
938 if (stored_rc) 937 if (stored_rc)
@@ -944,7 +943,7 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
944 } 943 }
945 944
946 if (num) { 945 if (num) {
947 stored_rc = cifs_lockv(xid, tcon, cfile->netfid, 946 stored_rc = cifs_lockv(xid, tcon, cfile->fid.netfid,
948 (__u8)types[i], 0, num, buf); 947 (__u8)types[i], 0, num, buf);
949 if (stored_rc) 948 if (stored_rc)
950 rc = stored_rc; 949 rc = stored_rc;
@@ -1038,7 +1037,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
1038 type = CIFS_WRLCK; 1037 type = CIFS_WRLCK;
1039 lck = list_entry(el, struct lock_to_push, llist); 1038 lck = list_entry(el, struct lock_to_push, llist);
1040 lck->pid = flock->fl_pid; 1039 lck->pid = flock->fl_pid;
1041 lck->netfid = cfile->netfid; 1040 lck->netfid = cfile->fid.netfid;
1042 lck->length = length; 1041 lck->length = length;
1043 lck->type = type; 1042 lck->type = type;
1044 lck->offset = flock->fl_start; 1043 lck->offset = flock->fl_start;
@@ -1137,7 +1136,7 @@ static int
1137cifs_mandatory_lock(unsigned int xid, struct cifsFileInfo *cfile, __u64 offset, 1136cifs_mandatory_lock(unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
1138 __u64 length, __u32 type, int lock, int unlock, bool wait) 1137 __u64 length, __u32 type, int lock, int unlock, bool wait)
1139{ 1138{
1140 return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->netfid, 1139 return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
1141 current->tgid, length, offset, unlock, lock, 1140 current->tgid, length, offset, unlock, lock,
1142 (__u8)type, wait, 0); 1141 (__u8)type, wait, 0);
1143} 1142}
@@ -1151,7 +1150,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1151 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; 1150 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
1152 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 1151 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1153 struct TCP_Server_Info *server = tcon->ses->server; 1152 struct TCP_Server_Info *server = tcon->ses->server;
1154 __u16 netfid = cfile->netfid; 1153 __u16 netfid = cfile->fid.netfid;
1155 1154
1156 if (posix_lck) { 1155 if (posix_lck) {
1157 int posix_lock_type; 1156 int posix_lock_type;
@@ -1295,7 +1294,8 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
1295 */ 1294 */
1296 list_move(&li->llist, &tmp_llist); 1295 list_move(&li->llist, &tmp_llist);
1297 if (++num == max_num) { 1296 if (++num == max_num) {
1298 stored_rc = cifs_lockv(xid, tcon, cfile->netfid, 1297 stored_rc = cifs_lockv(xid, tcon,
1298 cfile->fid.netfid,
1299 li->type, num, 0, buf); 1299 li->type, num, 0, buf);
1300 if (stored_rc) { 1300 if (stored_rc) {
1301 /* 1301 /*
@@ -1318,7 +1318,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
1318 cur++; 1318 cur++;
1319 } 1319 }
1320 if (num) { 1320 if (num) {
1321 stored_rc = cifs_lockv(xid, tcon, cfile->netfid, 1321 stored_rc = cifs_lockv(xid, tcon, cfile->fid.netfid,
1322 types[i], num, 0, buf); 1322 types[i], num, 0, buf);
1323 if (stored_rc) { 1323 if (stored_rc) {
1324 cifs_move_llist(&tmp_llist, &cfile->llist); 1324 cifs_move_llist(&tmp_llist, &cfile->llist);
@@ -1343,7 +1343,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1343 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; 1343 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
1344 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 1344 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1345 struct TCP_Server_Info *server = tcon->ses->server; 1345 struct TCP_Server_Info *server = tcon->ses->server;
1346 __u16 netfid = cfile->netfid; 1346 __u16 netfid = cfile->fid.netfid;
1347 1347
1348 if (posix_lck) { 1348 if (posix_lck) {
1349 int posix_lock_type; 1349 int posix_lock_type;
@@ -1423,7 +1423,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
1423 tcon->ses->server); 1423 tcon->ses->server);
1424 1424
1425 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1425 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1426 netfid = cfile->netfid; 1426 netfid = cfile->fid.netfid;
1427 cinode = CIFS_I(file->f_path.dentry->d_inode); 1427 cinode = CIFS_I(file->f_path.dentry->d_inode);
1428 1428
1429 if (cap_unix(tcon->ses) && 1429 if (cap_unix(tcon->ses) &&
@@ -1514,7 +1514,7 @@ static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid,
1514 /* iov[0] is reserved for smb header */ 1514 /* iov[0] is reserved for smb header */
1515 iov[1].iov_base = (char *)write_data + total_written; 1515 iov[1].iov_base = (char *)write_data + total_written;
1516 iov[1].iov_len = len; 1516 iov[1].iov_len = len;
1517 io_parms.netfid = open_file->netfid; 1517 io_parms.netfid = open_file->fid.netfid;
1518 io_parms.pid = pid; 1518 io_parms.pid = pid;
1519 io_parms.tcon = pTcon; 1519 io_parms.tcon = pTcon;
1520 io_parms.offset = *poffset; 1520 io_parms.offset = *poffset;
@@ -2078,7 +2078,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
2078 2078
2079 tcon = tlink_tcon(smbfile->tlink); 2079 tcon = tlink_tcon(smbfile->tlink);
2080 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) 2080 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
2081 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 2081 rc = CIFSSMBFlush(xid, tcon, smbfile->fid.netfid);
2082 2082
2083 free_xid(xid); 2083 free_xid(xid);
2084 mutex_unlock(&inode->i_mutex); 2084 mutex_unlock(&inode->i_mutex);
@@ -2106,7 +2106,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
2106 2106
2107 tcon = tlink_tcon(smbfile->tlink); 2107 tcon = tlink_tcon(smbfile->tlink);
2108 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) 2108 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
2109 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 2109 rc = CIFSSMBFlush(xid, tcon, smbfile->fid.netfid);
2110 2110
2111 free_xid(xid); 2111 free_xid(xid);
2112 mutex_unlock(&inode->i_mutex); 2112 mutex_unlock(&inode->i_mutex);
@@ -2802,7 +2802,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2802 if (rc != 0) 2802 if (rc != 0)
2803 break; 2803 break;
2804 } 2804 }
2805 io_parms.netfid = open_file->netfid; 2805 io_parms.netfid = open_file->fid.netfid;
2806 io_parms.pid = pid; 2806 io_parms.pid = pid;
2807 io_parms.tcon = tcon; 2807 io_parms.tcon = tcon;
2808 io_parms.offset = *poffset; 2808 io_parms.offset = *poffset;
@@ -3374,7 +3374,7 @@ void cifs_oplock_break(struct work_struct *work)
3374 * disconnected since oplock already released by the server 3374 * disconnected since oplock already released by the server
3375 */ 3375 */
3376 if (!cfile->oplock_break_cancelled) { 3376 if (!cfile->oplock_break_cancelled) {
3377 rc = CIFSSMBLock(0, tlink_tcon(cfile->tlink), cfile->netfid, 3377 rc = CIFSSMBLock(0, tlink_tcon(cfile->tlink), cfile->fid.netfid,
3378 current->tgid, 0, 0, 0, 0, 3378 current->tgid, 0, 0, 0, 0,
3379 LOCKING_ANDX_OPLOCK_RELEASE, false, 3379 LOCKING_ANDX_OPLOCK_RELEASE, false,
3380 cinode->clientCanCacheRead ? 1 : 0); 3380 cinode->clientCanCacheRead ? 1 : 0);