From patchwork Thu Sep 5 20:15:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 2854219 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E83E5C0AB5 for ; Thu, 5 Sep 2013 20:15:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D26DD202E9 for ; Thu, 5 Sep 2013 20:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0246202C3 for ; Thu, 5 Sep 2013 20:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755756Ab3IEUPY (ORCPT ); Thu, 5 Sep 2013 16:15:24 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:61374 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755698Ab3IEUPX (ORCPT ); Thu, 5 Sep 2013 16:15:23 -0400 Received: by mail-lb0-f169.google.com with SMTP id z5so2146453lbh.28 for ; Thu, 05 Sep 2013 13:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=/x45mqh1rO8YYfmbeJydQQJEbXkLROL/hTxUaBHRy1A=; b=b858Fn3PfxrUMtvqoVYjDdGd07k/mdW6RVUfkeYs+kaiUqkUtMJTlhq6XDAnnfUkav 90b9MyKbtCWHBDj+56DQghJLU+aDeGh/YrPSPk03kYrMpc5Tsl/o3bSWnbDwxH+E5yID +99H9sUG+d210eMwS+kJipDFiqGECx/b2Q2eJdmqjXwh+8p5uYyYyRvFSDGyy1DpYVYh gifRRR/DtdBNILjgCh3gz4MlqEA5iRf6Y5qjVX+1KJC+Y0ZSJ3/IKlHBel9mT+U2t0pd hWmHhfre2MliNVaeU7R+4CzDehZi4CjDeZp7tuoR3woXL1ovldkxvduGwHyPQitvFaB+ gTtg== X-Received: by 10.152.115.242 with SMTP id jr18mr56340lab.40.1378412122461; Thu, 05 Sep 2013 13:15:22 -0700 (PDT) Received: from localhost.localdomain (PPPoE-78-29-73-111.san.ru. [78.29.73.111]) by mx.google.com with ESMTPSA id js17sm14943043lab.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 13:15:21 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 6/8] CIFS: Move parsing lease buffer to ops struct Date: Fri, 6 Sep 2013 00:15:01 +0400 Message-Id: <1378412103-29047-7-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378412103-29047-1-git-send-email-pshilovsky@samba.org> References: <1378412103-29047-1-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsglob.h | 1 + fs/cifs/smb2ops.c | 13 +++++++++++++ fs/cifs/smb2pdu.c | 27 ++++++++++----------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 222a524..471d8f9 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -377,6 +377,7 @@ struct smb_version_operations { bool (*is_read_op)(__u32); void (*set_oplock_level)(struct cifsInodeInfo *, __u32); char * (*create_lease_buf)(u8 *, u8); + __u8 (*parse_lease_buf)(void *); }; struct smb_version_values { diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index ecff4d6..0215e60 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -748,6 +748,16 @@ smb2_create_lease_buf(u8 *lease_key, u8 oplock) return (char *)buf; } +static __u8 +smb2_parse_lease_buf(void *buf) +{ + struct create_lease *lc = (struct create_lease *)buf; + + if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) + return SMB2_OPLOCK_LEVEL_NOCHANGE; + return le32_to_cpu(lc->lcontext.LeaseState); +} + struct smb_version_operations smb20_operations = { .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request, @@ -816,6 +826,7 @@ struct smb_version_operations smb20_operations = { .is_read_op = smb2_is_read_op, .set_oplock_level = smb2_set_oplock_level, .create_lease_buf = smb2_create_lease_buf, + .parse_lease_buf = smb2_parse_lease_buf, }; struct smb_version_operations smb21_operations = { @@ -886,6 +897,7 @@ struct smb_version_operations smb21_operations = { .is_read_op = smb21_is_read_op, .set_oplock_level = smb21_set_oplock_level, .create_lease_buf = smb2_create_lease_buf, + .parse_lease_buf = smb2_parse_lease_buf, }; struct smb_version_operations smb30_operations = { @@ -958,6 +970,7 @@ struct smb_version_operations smb30_operations = { .is_read_op = smb21_is_read_op, .set_oplock_level = smb21_set_oplock_level, .create_lease_buf = smb2_create_lease_buf, + .parse_lease_buf = smb2_parse_lease_buf, }; struct smb_version_values smb20_values = { diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index c47b476..603d311 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -861,34 +861,27 @@ create_reconnect_durable_buf(struct cifs_fid *fid) } static __u8 -parse_lease_state(struct smb2_create_rsp *rsp) +parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp) { char *data_offset; - struct create_lease *lc; - bool found = false; + struct create_context *cc; unsigned int next = 0; char *name; data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset); - lc = (struct create_lease *)data_offset; + cc = (struct create_context *)data_offset; do { - lc = (struct create_lease *)((char *)lc + next); - name = le16_to_cpu(lc->ccontext.NameOffset) + (char *)lc; - if (le16_to_cpu(lc->ccontext.NameLength) != 4 || + cc = (struct create_context *)((char *)cc + next); + name = le16_to_cpu(cc->NameOffset) + (char *)cc; + if (le16_to_cpu(cc->NameLength) != 4 || strncmp(name, "RqLs", 4)) { - next = le32_to_cpu(lc->ccontext.Next); + next = le32_to_cpu(cc->Next); continue; } - if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) - return SMB2_OPLOCK_LEVEL_NOCHANGE; - found = true; - break; + return server->ops->parse_lease_buf(cc); } while (next != 0); - if (!found) - return 0; - - return le32_to_cpu(lc->lcontext.LeaseState); + return 0; } static int @@ -1070,7 +1063,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, } if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) - *oplock = parse_lease_state(rsp); + *oplock = parse_lease_state(server, rsp); else *oplock = rsp->OplockLevel; creat_exit: