diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-07-23 13:28:37 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-07-23 17:36:29 -0400 |
commit | c5fd363d771393a7b42bbbe051f30f97d4867a40 (patch) | |
tree | 338135e4be3a6f12a7c1350655cfc48b1db52457 /fs/cifs | |
parent | ac3aa2f8ae29c186c4742d15e39712af417c6d68 (diff) |
cifs: move file_lock off stack in cifs_push_posix_locks
struct file_lock is pretty large, so we really don't want that on the
stack in a potentially long call chain. Reorganize the arguments to
CIFSSMBPosixLock to eliminate the need for that.
Eliminate the get_flag and simply use a non-NULL pLockInfo to indicate
that this is a "get" operation. In order to do that, need to add a new
loff_t argument for the start_offset.
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsproto.h | 5 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 16 | ||||
-rw-r--r-- | fs/cifs/file.c | 8 |
3 files changed, 13 insertions, 16 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 0a6cbfe2761e..baa1b6dc838e 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -386,8 +386,9 @@ extern int CIFSSMBLock(const int xid, struct cifs_tcon *tcon, | |||
386 | const bool waitFlag, const __u8 oplock_level); | 386 | const bool waitFlag, const __u8 oplock_level); |
387 | extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | 387 | extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, |
388 | const __u16 smb_file_id, const __u32 netpid, | 388 | const __u16 smb_file_id, const __u32 netpid, |
389 | const int get_flag, const __u64 len, struct file_lock *, | 389 | const loff_t start_offset, const __u64 len, |
390 | const __u16 lock_type, const bool waitFlag); | 390 | struct file_lock *, const __u16 lock_type, |
391 | const bool waitFlag); | ||
391 | extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon); | 392 | extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon); |
392 | extern int CIFSSMBEcho(struct TCP_Server_Info *server); | 393 | extern int CIFSSMBEcho(struct TCP_Server_Info *server); |
393 | extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses); | 394 | extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses); |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 684a0723021f..5659850f780a 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -2356,9 +2356,10 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon, | |||
2356 | 2356 | ||
2357 | int | 2357 | int |
2358 | CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | 2358 | CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, |
2359 | const __u16 smb_file_id, const __u32 netpid, const int get_flag, | 2359 | const __u16 smb_file_id, const __u32 netpid, |
2360 | const __u64 len, struct file_lock *pLockData, | 2360 | const loff_t start_offset, const __u64 len, |
2361 | const __u16 lock_type, const bool waitFlag) | 2361 | struct file_lock *pLockData, const __u16 lock_type, |
2362 | const bool waitFlag) | ||
2362 | { | 2363 | { |
2363 | struct smb_com_transaction2_sfi_req *pSMB = NULL; | 2364 | struct smb_com_transaction2_sfi_req *pSMB = NULL; |
2364 | struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; | 2365 | struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; |
@@ -2372,9 +2373,6 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | |||
2372 | 2373 | ||
2373 | cFYI(1, "Posix Lock"); | 2374 | cFYI(1, "Posix Lock"); |
2374 | 2375 | ||
2375 | if (pLockData == NULL) | ||
2376 | return -EINVAL; | ||
2377 | |||
2378 | rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); | 2376 | rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); |
2379 | 2377 | ||
2380 | if (rc) | 2378 | if (rc) |
@@ -2395,7 +2393,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | |||
2395 | pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */ | 2393 | pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */ |
2396 | pSMB->SetupCount = 1; | 2394 | pSMB->SetupCount = 1; |
2397 | pSMB->Reserved3 = 0; | 2395 | pSMB->Reserved3 = 0; |
2398 | if (get_flag) | 2396 | if (pLockData) |
2399 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); | 2397 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); |
2400 | else | 2398 | else |
2401 | pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); | 2399 | pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); |
@@ -2417,7 +2415,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | |||
2417 | pSMB->Timeout = 0; | 2415 | pSMB->Timeout = 0; |
2418 | 2416 | ||
2419 | parm_data->pid = cpu_to_le32(netpid); | 2417 | parm_data->pid = cpu_to_le32(netpid); |
2420 | parm_data->start = cpu_to_le64(pLockData->fl_start); | 2418 | parm_data->start = cpu_to_le64(start_offset); |
2421 | parm_data->length = cpu_to_le64(len); /* normalize negative numbers */ | 2419 | parm_data->length = cpu_to_le64(len); /* normalize negative numbers */ |
2422 | 2420 | ||
2423 | pSMB->DataOffset = cpu_to_le16(offset); | 2421 | pSMB->DataOffset = cpu_to_le16(offset); |
@@ -2441,7 +2439,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, | |||
2441 | 2439 | ||
2442 | if (rc) { | 2440 | if (rc) { |
2443 | cFYI(1, "Send error in Posix Lock = %d", rc); | 2441 | cFYI(1, "Send error in Posix Lock = %d", rc); |
2444 | } else if (get_flag) { | 2442 | } else if (pLockData) { |
2445 | /* lock structure can be returned on get */ | 2443 | /* lock structure can be returned on get */ |
2446 | __u16 data_offset; | 2444 | __u16 data_offset; |
2447 | __u16 data_count; | 2445 | __u16 data_count; |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index dd28caa0a5ce..e9a8ac0047c7 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -1039,12 +1039,10 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) | |||
1039 | unlock_flocks(); | 1039 | unlock_flocks(); |
1040 | 1040 | ||
1041 | list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { | 1041 | list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { |
1042 | struct file_lock tmp_lock; | ||
1043 | int stored_rc; | 1042 | int stored_rc; |
1044 | 1043 | ||
1045 | tmp_lock.fl_start = lck->offset; | ||
1046 | stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid, | 1044 | stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid, |
1047 | 0, lck->length, &tmp_lock, | 1045 | lck->offset, lck->length, NULL, |
1048 | lck->type, 0); | 1046 | lck->type, 0); |
1049 | if (stored_rc) | 1047 | if (stored_rc) |
1050 | rc = stored_rc; | 1048 | rc = stored_rc; |
@@ -1159,7 +1157,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, | |||
1159 | else | 1157 | else |
1160 | posix_lock_type = CIFS_WRLCK; | 1158 | posix_lock_type = CIFS_WRLCK; |
1161 | rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, | 1159 | rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, |
1162 | 1 /* get */, length, flock, | 1160 | flock->fl_start, length, flock, |
1163 | posix_lock_type, wait_flag); | 1161 | posix_lock_type, wait_flag); |
1164 | return rc; | 1162 | return rc; |
1165 | } | 1163 | } |
@@ -1353,7 +1351,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, | |||
1353 | posix_lock_type = CIFS_UNLCK; | 1351 | posix_lock_type = CIFS_UNLCK; |
1354 | 1352 | ||
1355 | rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, | 1353 | rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, |
1356 | 0 /* set */, length, flock, | 1354 | flock->fl_start, length, NULL, |
1357 | posix_lock_type, wait_flag); | 1355 | posix_lock_type, wait_flag); |
1358 | goto out; | 1356 | goto out; |
1359 | } | 1357 | } |