From patchwork Mon Jul 23 17:31:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1228361 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B24F83FD4F for ; Mon, 23 Jul 2012 17:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754151Ab2GWRbg (ORCPT ); Mon, 23 Jul 2012 13:31:36 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:42630 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754141Ab2GWRbf (ORCPT ); Mon, 23 Jul 2012 13:31:35 -0400 Received: by yenl2 with SMTP id l2so5717606yen.19 for ; Mon, 23 Jul 2012 10:31:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=ZomRgupfj/zKjla5GZGdJOy7897NAjZee4EKC8+ls9Y=; b=eyJKeSFqsw3Cq3WsW4kmeHdzpHCyv9tVxoSIk+TYr1Hhe3OK88dDVQmJlpxJqo2st6 ZJDLZyZ0UnYZytPYzn0OI6FQCC6QizAgpLFLsjNOZBNd51ZzbtPfDfHS3UGeOlieVuD6 YQgAhdVnbWLqRbZVQAZLP9xx0NgB7qwP8qIxoT4UERsSlszC2Jy5zZAFi2DQs2+I8CdS x5LBM4HG7W8PtuAhapCetFVZ60RTi1R2hxK21HtRnW4JG256Wzd2YDcibd1IDIe1NyEJ rX9iaq9NldUFf8KRIzTEkAI0o/Rxfe1TPf6nTsHzgp+siIwK3ZM5TfHjM6dO0R2FVZi4 KA+w== Received: by 10.236.190.163 with SMTP id e23mr8314115yhn.36.1343064694622; Mon, 23 Jul 2012 10:31:34 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id y10sm25188740yhd.6.2012.07.23.10.31.33 (version=SSLv3 cipher=OTHER); Mon, 23 Jul 2012 10:31:33 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, viro@ZenIV.linux.org.uk Subject: [PATCH] cifs: move file_lock off stack in cifs_push_posix_locks Date: Mon, 23 Jul 2012 13:31:28 -0400 Message-Id: <1343064688-26053-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQnm3kbOzjRUdnmJuK2n8nTlCchHwuzol/rU2QSGi+ynTZpXKw/tr8xgww81UISGiSS5kety Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 Signed-off-by: Jeff Layton --- fs/cifs/cifsproto.h | 5 +++-- fs/cifs/cifssmb.c | 16 +++++++--------- 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 0a6cbfe..baa1b6d 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, const bool waitFlag, const __u8 oplock_level); extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, const __u16 smb_file_id, const __u32 netpid, - const int get_flag, const __u64 len, struct file_lock *, - const __u16 lock_type, const bool waitFlag); + const loff_t start_offset, const __u64 len, + struct file_lock *, const __u16 lock_type, + const bool waitFlag); extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon); extern int CIFSSMBEcho(struct TCP_Server_Info *server); extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses); diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 684a072..5659850 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -2356,9 +2356,10 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon, int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, - const __u16 smb_file_id, const __u32 netpid, const int get_flag, - const __u64 len, struct file_lock *pLockData, - const __u16 lock_type, const bool waitFlag) + const __u16 smb_file_id, const __u32 netpid, + const loff_t start_offset, const __u64 len, + struct file_lock *pLockData, const __u16 lock_type, + const bool waitFlag) { struct smb_com_transaction2_sfi_req *pSMB = 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"); - if (pLockData == NULL) - return -EINVAL; - rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); 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->SetupCount = 1; pSMB->Reserved3 = 0; - if (get_flag) + if (pLockData) pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); else pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); @@ -2417,7 +2415,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, pSMB->Timeout = 0; 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 */ pSMB->DataOffset = cpu_to_le16(offset); @@ -2441,7 +2439,7 @@ CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon, if (rc) { cFYI(1, "Send error in Posix Lock = %d", rc); - } else if (get_flag) { + } else if (pLockData) { /* lock structure can be returned on get */ __u16 data_offset; __u16 data_count; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index dd28caa..e9a8ac0 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1039,12 +1039,10 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) unlock_flocks(); list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { - struct file_lock tmp_lock; int stored_rc; - tmp_lock.fl_start = lck->offset; stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid, - 0, lck->length, &tmp_lock, + lck->offset, lck->length, NULL, lck->type, 0); if (stored_rc) rc = stored_rc; @@ -1159,7 +1157,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, else posix_lock_type = CIFS_WRLCK; rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, - 1 /* get */, length, flock, + flock->fl_start, length, flock, posix_lock_type, wait_flag); return rc; } @@ -1353,7 +1351,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, posix_lock_type = CIFS_UNLCK; rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid, - 0 /* set */, length, flock, + flock->fl_start, length, NULL, posix_lock_type, wait_flag); goto out; }