From patchwork Mon Sep 10 12:19:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1431981 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 E26E340220 for ; Mon, 10 Sep 2012 12:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757684Ab2IJMTs (ORCPT ); Mon, 10 Sep 2012 08:19:48 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:39807 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757660Ab2IJMTr (ORCPT ); Mon, 10 Sep 2012 08:19:47 -0400 Received: by lbbgj3 with SMTP id gj3so1125411lbb.19 for ; Mon, 10 Sep 2012 05:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=47cBSrAvW0Ybak6XBFSRkJxk8deyup40Bc8AV/NyCwA=; b=0tf0iOuIsm8aAdCYmyuyYWyslqj9cQfe+W4HZD2LnHg9wxDM1fOyr/49A8puj7J0qM qvFzV92fUYUMZ39W4HrdGNKIZZdlAaYNhnXxIjmHIy9IF0qy3XWCd31ezVlPzTdsqNiT aBlYmf76/9Wmp0ky0wKEShEXgtkD60QqaP3kH4y51P2uzq0hlFO33A4/IF1pVx9erVhO SdzoqmFjLaZrUcoKGD9suCQW7Q296nTVbRtpeyn/VnDENzFtRlbPeZzxXKrpDq/Byl4E FwYtmPFGqL38yIZAhptzl321bpn1E4713f3oU96tHUwXqNzYLjlR6XGeYbS1VGiGgozp J4DQ== Received: by 10.112.51.228 with SMTP id n4mr4931086lbo.55.1347279585997; Mon, 10 Sep 2012 05:19:45 -0700 (PDT) Received: from localhost.localdomain ([178.45.128.11]) by mx.google.com with ESMTPS id r8sm3514851lba.15.2012.09.10.05.19.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 10 Sep 2012 05:19:45 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Cc: Pavel Shilovsky Subject: [PATCH v3 2/7] CIFS: Move brlock code to ops struct Date: Mon, 10 Sep 2012 16:19:30 +0400 Message-Id: <1347279575-6071-3-git-send-email-pshilovsky@etersoft.ru> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1347279575-6071-1-git-send-email-pshilovsky@etersoft.ru> References: <1347279575-6071-1-git-send-email-pshilovsky@etersoft.ru> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Pavel Shilovsky Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsglob.h | 8 ++++++++ fs/cifs/cifsproto.h | 3 +++ fs/cifs/file.c | 42 +++++++++++++++++------------------------- fs/cifs/smb1ops.c | 12 ++++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index b2eb577..d3c7271 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -353,6 +353,14 @@ struct smb_version_operations { /* query remote filesystem */ int (*queryfs)(const unsigned int, struct cifs_tcon *, struct kstatfs *); + /* send mandatory brlock to the server */ + int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64, + __u64, __u32, int, int, bool); + /* unlock range of mandatory locks */ + int (*mand_unlock_range)(struct cifsFileInfo *, struct file_lock *, + const unsigned int); + /* push brlocks from the cache to the server */ + int (*push_mand_locks)(struct cifsFileInfo *); }; struct smb_version_values { diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 3b628f2..a7e238f 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -124,6 +124,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec); extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset); extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); +extern int cifs_unlock_range(struct cifsFileInfo *cfile, + struct file_lock *flock, const unsigned int xid); +extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile); extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 6787b7f..fc65f07 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -903,7 +903,7 @@ try_again: return rc; } -static int +int cifs_push_mandatory_locks(struct cifsFileInfo *cfile) { unsigned int xid; @@ -1111,7 +1111,7 @@ cifs_push_locks(struct cifsFileInfo *cfile) ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) return cifs_push_posix_locks(cfile); - return cifs_push_mandatory_locks(cfile); + return tcon->ses->server->ops->push_mand_locks(cfile); } static void @@ -1162,15 +1162,6 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock, } static int -cifs_mandatory_lock(unsigned int xid, struct cifsFileInfo *cfile, __u64 offset, - __u64 length, __u32 type, int lock, int unlock, bool wait) -{ - return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid, - current->tgid, length, offset, unlock, lock, - (__u8)type, wait, 0); -} - -static int cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, bool wait_flag, bool posix_lck, unsigned int xid) { @@ -1203,11 +1194,11 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, return rc; /* BB we could chain these into one lock request BB */ - rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, type, - 1, 0, false); + rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type, + 1, 0, false); if (rc == 0) { - rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, - type, 0, 1, false); + rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, + type, 0, 1, false); flock->fl_type = F_UNLCK; if (rc != 0) cERROR(1, "Error unlocking previously locked " @@ -1220,13 +1211,14 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, return 0; } - rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, - type | server->vals->shared_lock_type, 1, 0, - false); + type &= ~server->vals->exclusive_lock_type; + + rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, + type | server->vals->shared_lock_type, + 1, 0, false); if (rc == 0) { - rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, - type | server->vals->shared_lock_type, - 0, 1, false); + rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, + type | server->vals->shared_lock_type, 0, 1, false); flock->fl_type = F_RDLCK; if (rc != 0) cERROR(1, "Error unlocking previously locked " @@ -1256,7 +1248,7 @@ cifs_free_llist(struct list_head *llist) } } -static int +int cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, unsigned int xid) { @@ -1408,8 +1400,8 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, if (rc <= 0) goto out; - rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, - type, 1, 0, wait_flag); + rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, + type, 1, 0, wait_flag); if (rc) { kfree(lock); goto out; @@ -1417,7 +1409,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, cifs_lock_add(cfile, lock); } else if (unlock) - rc = cifs_unlock_range(cfile, flock, xid); + rc = server->ops->mand_unlock_range(cfile, flock, xid); out: if (flock->fl_flags & FL_POSIX) diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index ed7f955..5fb0fe5 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -899,6 +899,15 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon, return rc; } +static int +cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset, + __u64 length, __u32 type, int lock, int unlock, bool wait) +{ + return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid, + current->tgid, length, offset, unlock, lock, + (__u8)type, wait, 0); +} + struct smb_version_operations smb1_operations = { .send_cancel = send_nt_cancel, .compare_fids = cifs_compare_fids, @@ -960,6 +969,9 @@ struct smb_version_operations smb1_operations = { .calc_smb_size = smbCalcSize, .oplock_response = cifs_oplock_response, .queryfs = cifs_queryfs, + .mand_lock = cifs_mand_lock, + .mand_unlock_range = cifs_unlock_range, + .push_mand_locks = cifs_push_mandatory_locks, }; struct smb_version_values smb1_values = {