From patchwork Wed Jul 18 15:48:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1211991 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 B80DB3FD4F for ; Wed, 18 Jul 2012 15:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754511Ab2GRPuS (ORCPT ); Wed, 18 Jul 2012 11:50:18 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:33500 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754501Ab2GRPuR (ORCPT ); Wed, 18 Jul 2012 11:50:17 -0400 Received: by eekc13 with SMTP id c13so594931eek.19 for ; Wed, 18 Jul 2012 08:50:16 -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:x-mailer:in-reply-to :references; bh=0MBPN3Qn0PHCMUw5fmXR+sqtX5lgvIM1lbDR+gt+YDY=; b=RjF1s96bSrzIxWAe2y8q6ag4MidhZ5pDFs8gqsncGpYPPoPV6vMkRzZl28E0bfyYY1 1WlfstAulCMTAnSHnvd3YPxGaJdkf7eSREO4PCsTkDkvxkjOYThITljWG7VZj4qQujIE ZscWj13OOHEsLiR6TDchZ1V7i+BFPUT2htypGsNvCX+IOunXMA5XfsjViIzVDf2toRFp ye7/xkmKSXTll/LJ24hNOpIxockDwkaIQlIVpZ/2eZVJ8PG3olDgZfuU8ZiLXQgY5+l0 JGdOjwbGE0C6vhQT6GnC4t3S8Z8F5kxYbUld48S6IR7ZRpczAAwt9Qv6wqBjeVMn3x65 MiNA== Received: by 10.152.125.133 with SMTP id mq5mr4098090lab.12.1342626616352; Wed, 18 Jul 2012 08:50:16 -0700 (PDT) Received: from localhost.localdomain ([178.45.208.11]) by mx.google.com with ESMTPS id p2sm4826985lbj.4.2012.07.18.08.50.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 08:50:15 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 12/45] CIFS: Move close code to ops struct Date: Wed, 18 Jul 2012 19:48:28 +0400 Message-Id: <1342626541-29872-13-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1342626541-29872-1-git-send-email-pshilovsky@samba.org> References: <1342626541-29872-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 Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsglob.h | 2 ++ fs/cifs/file.c | 10 +++++++--- fs/cifs/smb1ops.c | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index c4375d8..b3cbce6 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -269,6 +269,8 @@ struct smb_version_operations { struct cifs_sb_info *); /* set fid protocol-specific info */ void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32); + /* close a file */ + int (*close)(const unsigned int, struct cifs_tcon *, struct cifs_fid *); }; struct smb_version_values { diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 3f4b4ba..b18b36a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -317,10 +317,13 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file) cancel_work_sync(&cifs_file->oplock_break); if (!tcon->need_reconnect && !cifs_file->invalidHandle) { + struct TCP_Server_Info *server = tcon->ses->server; unsigned int xid; - int rc; + int rc = -ENOSYS; + xid = get_xid(); - rc = CIFSSMBClose(xid, tcon, cifs_file->fid.netfid); + if (server->ops->close) + rc = server->ops->close(xid, tcon, &cifs_file->fid); free_xid(xid); } @@ -414,7 +417,8 @@ int cifs_open(struct inode *inode, struct file *file) cfile = cifs_new_fileinfo(&fid, file, tlink, oplock); if (cfile == NULL) { - CIFSSMBClose(xid, tcon, fid.netfid); + if (tcon->ses->server->ops->close) + tcon->ses->server->ops->close(xid, tcon, &fid); rc = -ENOMEM; goto out; } diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index 907b308..bb75847 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -634,6 +634,13 @@ cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) cinode->can_cache_brlcks = cinode->clientCanCacheAll; } +static int +cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon, + struct cifs_fid *fid) +{ + return CIFSSMBClose(xid, tcon, fid->netfid); +} + struct smb_version_operations smb1_operations = { .send_cancel = send_nt_cancel, .compare_fids = cifs_compare_fids, @@ -675,6 +682,7 @@ struct smb_version_operations smb1_operations = { .rename_pending_delete = cifs_rename_pending_delete, .open = cifs_open_file, .set_fid = cifs_set_fid, + .close = cifs_close_file, }; struct smb_version_values smb1_values = {