From patchwork Mon Dec 13 15:00:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 406452 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBDF1Ocm017890 for ; Mon, 13 Dec 2010 15:01:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817Ab0LMPBX (ORCPT ); Mon, 13 Dec 2010 10:01:23 -0500 Received: from mail-ew0-f45.google.com ([209.85.215.45]:37976 "EHLO mail-ew0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969Ab0LMPBX (ORCPT ); Mon, 13 Dec 2010 10:01:23 -0500 Received: by ewy10 with SMTP id 10so3926985ewy.4 for ; Mon, 13 Dec 2010 07:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=2E8ROkLtbO8ShuRxrLjuaRJ5J9NhCUIFL6bgO18eFfA=; b=Ev4043uAX4ddUXJkfug+HDVCMzN5tKQWnkfosrX+5bwl/5oJsLHJ8QBQv3rT3maFg2 GJSVvzMwB+INXVzl12u39GqjL5Cc1W9jzneCMyRZ69BoN5oVImWsOP+OVbNnjrXYmmQI MHbke2vjDsXphPNtIeIAKD2WpUCwSAFJ0aPFc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=e4ad+ldPB3Z2ijF9kYTV0edYJTY5L/4yWBtoczFpmGj2tmwVJoZBHDpLqDeuimN+gh 6Sg3ZbSqvOUjVZEviYcAA2ppjkpx5ZijZDIPknnquOG2C+yQp5P+1UUWcrIdOVZfqpBK zhS1Z2L5eomEmgTTZ552UlyITB/LvG2C0xpmU= Received: by 10.213.113.204 with SMTP id b12mr4041057ebq.54.1292252481576; Mon, 13 Dec 2010 07:01:21 -0800 (PST) Received: from localhost.localdomain (PPPoE-78-29-112-8.san.ru [78.29.112.8]) by mx.google.com with ESMTPS id w20sm148969eeh.0.2010.12.13.07.01.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 13 Dec 2010 07:01:19 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 2/7] CIFS: Add strict cache file operations Date: Mon, 13 Dec 2010 18:00:50 +0300 Message-Id: <1292252455-4025-2-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1292252455-4025-1-git-send-email-piastryyy@gmail.com> References: <1292252455-4025-1-git-send-email-piastryyy@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Dec 2010 15:01:25 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 3936aa7..a0e35d3 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -572,6 +572,22 @@ cifs_do_mount(struct file_system_type *fs_type, return dget(sb->s_root); } +static ssize_t cifs_strict_read(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + ssize_t read = 0; + /* BB */ + return read; +} + +static ssize_t cifs_strict_write(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + ssize_t written = 0; + /* BB */ + return written; +} + static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { @@ -710,6 +726,25 @@ const struct file_operations cifs_file_ops = { .setlease = cifs_setlease, }; +const struct file_operations cifs_file_strict_ops = { + .read = do_sync_read, + .write = do_sync_write, + .aio_read = cifs_strict_read, + .aio_write = cifs_strict_write, + .open = cifs_open, + .release = cifs_close, + .lock = cifs_lock, + .fsync = cifs_strict_fsync, + .flush = cifs_flush, + .mmap = cifs_file_strict_mmap, + .splice_read = generic_file_splice_read, + .llseek = cifs_llseek, +#ifdef CONFIG_CIFS_POSIX + .unlocked_ioctl = cifs_ioctl, +#endif /* CONFIG_CIFS_POSIX */ + .setlease = cifs_setlease, +}; + const struct file_operations cifs_file_direct_ops = { /* no aio, no readv - BB reevaluate whether they can be done with directio, no cache */ @@ -728,6 +763,7 @@ const struct file_operations cifs_file_direct_ops = { .llseek = cifs_llseek, .setlease = cifs_setlease, }; + const struct file_operations cifs_file_nobrl_ops = { .read = do_sync_read, .write = do_sync_write, @@ -746,6 +782,24 @@ const struct file_operations cifs_file_nobrl_ops = { .setlease = cifs_setlease, }; +const struct file_operations cifs_file_strict_nobrl_ops = { + .read = do_sync_read, + .write = do_sync_write, + .aio_read = cifs_strict_read, + .aio_write = cifs_strict_write, + .open = cifs_open, + .release = cifs_close, + .fsync = cifs_strict_fsync, + .flush = cifs_flush, + .mmap = cifs_file_strict_mmap, + .splice_read = generic_file_splice_read, + .llseek = cifs_llseek, +#ifdef CONFIG_CIFS_POSIX + .unlocked_ioctl = cifs_ioctl, +#endif /* CONFIG_CIFS_POSIX */ + .setlease = cifs_setlease, +}; + const struct file_operations cifs_file_direct_nobrl_ops = { /* no mmap, no aio, no readv - BB reevaluate whether they can be done with directio, no cache */ diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 897b2b2..e47c00d 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -72,8 +72,10 @@ extern const struct inode_operations cifs_dfs_referral_inode_operations; /* Functions related to files and directories */ extern const struct file_operations cifs_file_ops; extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */ -extern const struct file_operations cifs_file_nobrl_ops; -extern const struct file_operations cifs_file_direct_nobrl_ops; /* no brlocks */ +extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */ +extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */ +extern const struct file_operations cifs_file_direct_nobrl_ops; +extern const struct file_operations cifs_file_strict_nobrl_ops; extern int cifs_open(struct inode *inode, struct file *file); extern int cifs_close(struct inode *inode, struct file *file); extern int cifs_closedir(struct inode *inode, struct file *file); @@ -83,8 +85,10 @@ extern ssize_t cifs_user_write(struct file *file, const char __user *write_data, size_t write_size, loff_t *poffset); extern int cifs_lock(struct file *, int, struct file_lock *); extern int cifs_fsync(struct file *, int); +extern int cifs_strict_fsync(struct file *, int); extern int cifs_flush(struct file *, fl_owner_t id); extern int cifs_file_mmap(struct file * , struct vm_area_struct *); +extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *); extern const struct file_operations cifs_dir_ops; extern int cifs_dir_open(struct inode *inode, struct file *file); extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 60c3f84..626cfa3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1586,6 +1586,13 @@ static int cifs_write_end(struct file *file, struct address_space *mapping, return rc; } +int cifs_strict_fsync(struct file *file, int datasync) +{ + int rc = 0; + /* BB */ + return rc; +} + int cifs_fsync(struct file *file, int datasync) { int xid; @@ -1807,6 +1814,13 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, return total_read; } +int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) +{ + int rc = 0; + /* BB */ + return rc; +} + int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) { int rc, xid; diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 589f3e3..b245cf0 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -44,13 +44,17 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral) inode->i_fop = &cifs_file_direct_nobrl_ops; else inode->i_fop = &cifs_file_direct_ops; + } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) + inode->i_fop = &cifs_file_strict_nobrl_ops; + else + inode->i_fop = &cifs_file_strict_ops; } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) inode->i_fop = &cifs_file_nobrl_ops; else { /* not direct, send byte range locks */ inode->i_fop = &cifs_file_ops; } - /* check if server can support readpages */ if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf < PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)