From patchwork Wed Jul 18 15:48:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1212051 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 BFB563FD4F for ; Wed, 18 Jul 2012 15:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754692Ab2GRPu3 (ORCPT ); Wed, 18 Jul 2012 11:50:29 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:46425 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754501Ab2GRPu3 (ORCPT ); Wed, 18 Jul 2012 11:50:29 -0400 Received: by mail-bk0-f46.google.com with SMTP id j10so1564621bkw.19 for ; Wed, 18 Jul 2012 08:50:28 -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=mRRpDBQ8ZPUMl/cyTuDd/fFzimFMBE9KUTokQu7zlO0=; b=Xrcz4Cxi1eo7v9KBOXJjPFWZ/TvXH587LO9P6wuPztdZdQ5lswcer6LCz8z8dCMBU9 1Ppne857hae2BeRhTUhB9dEINSeoGu3s2kbgj3a/lGMGEBIFzoxRkYsZ/WGmJZ8AlC+9 +GFaS23cJTc9tYjrrNSJvBidSLRVjuPoPjbbhc44syxLwtRTwpgebaRts5qV0ggcTbbK A2PRwxjvdNW/5ric023PVD8KWj4BW3eBhfyZ4cLP0Ev9aP6J0kWHIcMIwGRltk7Pz5Qw 3G/lBhuPhjyZyBTdFcdJaDHVadSRESOrdyTLewRHKQ0TvRvWOO2U4L+qLrkVNhFSHQIe qguQ== Received: by 10.152.144.138 with SMTP id sm10mr4101504lab.22.1342626628274; Wed, 18 Jul 2012 08:50:28 -0700 (PDT) Received: from localhost.localdomain ([178.45.208.11]) by mx.google.com with ESMTPS id p2sm4826985lbj.4.2012.07.18.08.50.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 08:50:27 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 18/45] CIFS: Make flush code use ops struct Date: Wed, 18 Jul 2012 19:48:34 +0400 Message-Id: <1342626541-29872-19-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 | 20 ++++++++++++++++---- fs/cifs/smb1ops.c | 8 ++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 0467e38..3d94397 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -274,6 +274,8 @@ struct smb_version_operations { void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32); /* close a file */ int (*close)(const unsigned int, struct cifs_tcon *, struct cifs_fid *); + /* send a flush request to the server */ + int (*flush)(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 e8cca00..3f2cfb3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2055,6 +2055,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end, unsigned int xid; int rc = 0; struct cifs_tcon *tcon; + struct TCP_Server_Info *server; struct cifsFileInfo *smbfile = file->private_data; struct inode *inode = file->f_path.dentry->d_inode; struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); @@ -2078,8 +2079,13 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end, } tcon = tlink_tcon(smbfile->tlink); - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) - rc = CIFSSMBFlush(xid, tcon, smbfile->fid.netfid); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { + server = tcon->ses->server; + if (server->ops->flush) + rc = server->ops->flush(xid, tcon, &smbfile->fid); + else + rc = -ENOSYS; + } free_xid(xid); mutex_unlock(&inode->i_mutex); @@ -2091,6 +2097,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync) unsigned int xid; int rc = 0; struct cifs_tcon *tcon; + struct TCP_Server_Info *server; struct cifsFileInfo *smbfile = file->private_data; struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); struct inode *inode = file->f_mapping->host; @@ -2106,8 +2113,13 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync) file->f_path.dentry->d_name.name, datasync); tcon = tlink_tcon(smbfile->tlink); - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) - rc = CIFSSMBFlush(xid, tcon, smbfile->fid.netfid); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { + server = tcon->ses->server; + if (server->ops->flush) + rc = server->ops->flush(xid, tcon, &smbfile->fid); + else + rc = -ENOSYS; + } free_xid(xid); mutex_unlock(&inode->i_mutex); diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index dd64754..df20dd9 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -648,6 +648,13 @@ cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon, return CIFSSMBClose(xid, tcon, fid->netfid); } +static int +cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon, + struct cifs_fid *fid) +{ + return CIFSSMBFlush(xid, tcon, fid->netfid); +} + struct smb_version_operations smb1_operations = { .send_cancel = send_nt_cancel, .compare_fids = cifs_compare_fids, @@ -691,6 +698,7 @@ struct smb_version_operations smb1_operations = { .open = cifs_open_file, .set_fid = cifs_set_fid, .close = cifs_close_file, + .flush = cifs_flush_file, }; struct smb_version_values smb1_values = {