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>
This commit is contained in:
committed by
Steve French
parent
ac3aa2f8ae
commit
c5fd363d77
@@ -386,8 +386,9 @@ extern int CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
const bool waitFlag, const __u8 oplock_level);
|
const bool waitFlag, const __u8 oplock_level);
|
||||||
extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
||||||
const __u16 smb_file_id, const __u32 netpid,
|
const __u16 smb_file_id, const __u32 netpid,
|
||||||
const int get_flag, const __u64 len, struct file_lock *,
|
const loff_t start_offset, const __u64 len,
|
||||||
const __u16 lock_type, const bool waitFlag);
|
struct file_lock *, const __u16 lock_type,
|
||||||
|
const bool waitFlag);
|
||||||
extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon);
|
extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon);
|
||||||
extern int CIFSSMBEcho(struct TCP_Server_Info *server);
|
extern int CIFSSMBEcho(struct TCP_Server_Info *server);
|
||||||
extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses);
|
extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses);
|
||||||
|
@@ -2356,9 +2356,10 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
|
|
||||||
int
|
int
|
||||||
CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
||||||
const __u16 smb_file_id, const __u32 netpid, const int get_flag,
|
const __u16 smb_file_id, const __u32 netpid,
|
||||||
const __u64 len, struct file_lock *pLockData,
|
const loff_t start_offset, const __u64 len,
|
||||||
const __u16 lock_type, const bool waitFlag)
|
struct file_lock *pLockData, const __u16 lock_type,
|
||||||
|
const bool waitFlag)
|
||||||
{
|
{
|
||||||
struct smb_com_transaction2_sfi_req *pSMB = NULL;
|
struct smb_com_transaction2_sfi_req *pSMB = NULL;
|
||||||
struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
|
struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
|
||||||
@@ -2372,9 +2373,6 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
|
|
||||||
cFYI(1, "Posix Lock");
|
cFYI(1, "Posix Lock");
|
||||||
|
|
||||||
if (pLockData == NULL)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
|
rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
@@ -2395,7 +2393,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
|
pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
|
||||||
pSMB->SetupCount = 1;
|
pSMB->SetupCount = 1;
|
||||||
pSMB->Reserved3 = 0;
|
pSMB->Reserved3 = 0;
|
||||||
if (get_flag)
|
if (pLockData)
|
||||||
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
|
pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
|
||||||
else
|
else
|
||||||
pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
|
pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
|
||||||
@@ -2417,7 +2415,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
pSMB->Timeout = 0;
|
pSMB->Timeout = 0;
|
||||||
|
|
||||||
parm_data->pid = cpu_to_le32(netpid);
|
parm_data->pid = cpu_to_le32(netpid);
|
||||||
parm_data->start = cpu_to_le64(pLockData->fl_start);
|
parm_data->start = cpu_to_le64(start_offset);
|
||||||
parm_data->length = cpu_to_le64(len); /* normalize negative numbers */
|
parm_data->length = cpu_to_le64(len); /* normalize negative numbers */
|
||||||
|
|
||||||
pSMB->DataOffset = cpu_to_le16(offset);
|
pSMB->DataOffset = cpu_to_le16(offset);
|
||||||
@@ -2441,7 +2439,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
|
|||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
cFYI(1, "Send error in Posix Lock = %d", rc);
|
cFYI(1, "Send error in Posix Lock = %d", rc);
|
||||||
} else if (get_flag) {
|
} else if (pLockData) {
|
||||||
/* lock structure can be returned on get */
|
/* lock structure can be returned on get */
|
||||||
__u16 data_offset;
|
__u16 data_offset;
|
||||||
__u16 data_count;
|
__u16 data_count;
|
||||||
|
@@ -1039,12 +1039,10 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
|
|||||||
unlock_flocks();
|
unlock_flocks();
|
||||||
|
|
||||||
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
|
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
|
||||||
struct file_lock tmp_lock;
|
|
||||||
int stored_rc;
|
int stored_rc;
|
||||||
|
|
||||||
tmp_lock.fl_start = lck->offset;
|
|
||||||
stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid,
|
stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid,
|
||||||
0, lck->length, &tmp_lock,
|
lck->offset, lck->length, NULL,
|
||||||
lck->type, 0);
|
lck->type, 0);
|
||||||
if (stored_rc)
|
if (stored_rc)
|
||||||
rc = stored_rc;
|
rc = stored_rc;
|
||||||
@@ -1159,7 +1157,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
|
|||||||
else
|
else
|
||||||
posix_lock_type = CIFS_WRLCK;
|
posix_lock_type = CIFS_WRLCK;
|
||||||
rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid,
|
rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid,
|
||||||
1 /* get */, length, flock,
|
flock->fl_start, length, flock,
|
||||||
posix_lock_type, wait_flag);
|
posix_lock_type, wait_flag);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1353,7 +1351,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
|
|||||||
posix_lock_type = CIFS_UNLCK;
|
posix_lock_type = CIFS_UNLCK;
|
||||||
|
|
||||||
rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid,
|
rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid,
|
||||||
0 /* set */, length, flock,
|
flock->fl_start, length, NULL,
|
||||||
posix_lock_type, wait_flag);
|
posix_lock_type, wait_flag);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user