From patchwork Sun Nov 28 08:12:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 361862 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 oAS8BWvl023110 for ; Sun, 28 Nov 2010 08:14:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751760Ab0K1IOz (ORCPT ); Sun, 28 Nov 2010 03:14:55 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:58953 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751708Ab0K1IOy (ORCPT ); Sun, 28 Nov 2010 03:14:54 -0500 Received: by mail-ey0-f174.google.com with SMTP id 27so1481871eye.19 for ; Sun, 28 Nov 2010 00:14:54 -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=GV9n9GF0T9+2szAvA2lqt+62kk/tp0oICeIRvF/gxAY=; b=LAe+5V4gsCuxenEqSEkP+w62oVTGD9qDRVgsuFQk9/RU001HRRPtFWBGkH8abGnAFz oxzQ7W1LpKeA3zMLMtUWIKXO8NxIGYLcZOGnECJfhMGNGV0jW9BNDZTLoa4Z2y0Lptu3 L5P5lT0fU8s1JN8Su/F8GLXS4dIplTIIyRcKE= 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=rI7r6z0YByKGt6WJNuhFR0Df71dKff0+Q1PjYFCxELwOY/33iR4fXydZnv9B2q2CPa eLmBY37d9C5Y8LtrCC5nY9OMAQeaFrnO3nBy5VuKL39Q8B9VhjQU8ySXA3CyySXwdWFL 3G0mCWZ+W0lBVuDvfkdG9Ip4gVYULDgkCePug= Received: by 10.213.3.68 with SMTP id 4mr3818480ebm.0.1290932094067; Sun, 28 Nov 2010 00:14:54 -0800 (PST) Received: from localhost.localdomain ([95.84.39.194]) by mx.google.com with ESMTPS id b52sm3724422eei.19.2010.11.28.00.14.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Nov 2010 00:14:53 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 2/6] CIFS: Make read call work with strict cache mode (try #2) Date: Sun, 28 Nov 2010 11:12:48 +0300 Message-Id: <1290931972-2770-3-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1290931972-2770-1-git-send-email-piastryyy@gmail.com> References: <1290931972-2770-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]); Sun, 28 Nov 2010 08:14:55 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 9c37897..bbb5294 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -568,6 +568,33 @@ cifs_do_mount(struct file_system_type *fs_type, return dget(sb->s_root); } +static ssize_t cifs_file_aio_read(struct kiocb *iocb, const struct iovec *iov, + unsigned long nr_segs, loff_t pos) +{ + struct inode *inode; + struct cifs_sb_info *cifs_sb; + ssize_t read; + + inode = iocb->ki_filp->f_path.dentry->d_inode; + cifs_sb = CIFS_SB(iocb->ki_filp->f_path.dentry->d_sb); + + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) == 0 || + CIFS_I(inode)->clientCanCacheRead) + return generic_file_aio_read(iocb, iov, nr_segs, pos); + + /* in strict cache mode we need to read from the server all the time + if we don't have level II oplock because the server can delay mtime + change - so we can't make a decision about inode invalidating. + And we can also fail with pagereading if there are mandatory locks + on pages affected by this read but not on the region from pos to + pos+len-1 */ + read = cifs_user_read(iocb->ki_filp, iov->iov_base, + iov->iov_len, &pos); + iocb->ki_pos = pos; + + return read; +} + static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { @@ -690,7 +717,7 @@ const struct inode_operations cifs_symlink_inode_ops = { const struct file_operations cifs_file_ops = { .read = do_sync_read, .write = do_sync_write, - .aio_read = generic_file_aio_read, + .aio_read = cifs_file_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close, @@ -727,7 +754,7 @@ const struct file_operations cifs_file_direct_ops = { const struct file_operations cifs_file_nobrl_ops = { .read = do_sync_read, .write = do_sync_write, - .aio_read = generic_file_aio_read, + .aio_read = cifs_file_aio_read, .aio_write = cifs_file_aio_write, .open = cifs_open, .release = cifs_close,