From patchwork Wed Nov 10 15:41:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 314522 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 oAAFgYqX031219 for ; Wed, 10 Nov 2010 15:42:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756678Ab0KJPme (ORCPT ); Wed, 10 Nov 2010 10:42:34 -0500 Received: from mail-ew0-f46.google.com ([209.85.215.46]:34474 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756595Ab0KJPmd (ORCPT ); Wed, 10 Nov 2010 10:42:33 -0500 Received: by mail-ew0-f46.google.com with SMTP id 7so367214ewy.19 for ; Wed, 10 Nov 2010 07:42:33 -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=4bIjSr9/797YICH26H5esivFZfY174Vb/ua2sIWWIDI=; b=h6a6t6jc7d64Zl+TJU5IxE7cR5LHniPTaYc8x3LZJGPYhpnFv0F8XyaqgtII6siCam Djd/FlbubwQtqicCNwnfsLICGlnWuAnucNqW1Ljx+N36osRGY11c6/SXHkp0cNW5izYw sVcM8IhJHi3E/fIMNidKoWjy7VLaPwET4+6I0= 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=cj8vGUJyGczW2MRzvPlIl8gpoZ//0kvyFddJk5bdLYnd9PbUO7drTpMBZWFzFJ1nt9 AjvRBY7vaWLhOpYnH+bgjVYQ4Ugusb6xX+fVZHb1XNw5wvv1dZDYbAh2gtd6lGxezC9q ZxX3F6I1FnBt+en/8E8MAuebD5cod297b0NPc= Received: by 10.213.14.148 with SMTP id g20mr6472469eba.66.1289403752908; Wed, 10 Nov 2010 07:42:32 -0800 (PST) Received: from localhost.localdomain ([79.126.90.150]) by mx.google.com with ESMTPS id w20sm815303eeh.0.2010.11.10.07.42.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Nov 2010 07:42:32 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 2/6] CIFS: Make read call work with strict cache mode Date: Wed, 10 Nov 2010 18:41:47 +0300 Message-Id: <1289403711-12965-3-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1289403711-12965-1-git-send-email-piastryyy@gmail.com> References: <1289403711-12965-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]); Wed, 10 Nov 2010 15:42:34 +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,