From patchwork Sun Oct 31 19:44:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 293722 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 o9VJiFQO026702 for ; Sun, 31 Oct 2010 19:44:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756610Ab0JaToP (ORCPT ); Sun, 31 Oct 2010 15:44:15 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:43174 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232Ab0JaToO (ORCPT ); Sun, 31 Oct 2010 15:44:14 -0400 Received: by wyf28 with SMTP id 28so4823584wyf.19 for ; Sun, 31 Oct 2010 12:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=yLpUx+25KJgKDBEd0wwxjEaNZCT1mecUKu9/75r/cmY=; b=wbv4FLlfQcTwoqx9XKaGw1Kmo7Wy/ojoirPyJAY3mt5TX9CeTaL8bK8jHGaPPxPaMF 3o4qUB36xk9jCkw6oPDAwWoWNiNQLc7w/198YcaLz+81oyhDQ1eNidKwC5zJVrTufc8n lIsz6bXznSmDiq8qTkUm7bKfBjgHQuSwe2IMM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=lSH+yKgN/bP0G8Z8Uv7TJQtIbXeI3i84W9Oowt3RCrI/Pr8jgB9XO/H5M7DewFieAf hVaaaPHQxRoWc51dfjQ7RSOwOLka/y+avGdVvZq4GK5YJ9oTrnXWIfi/bt7jlQ/egmBf KluTBLNs2BWTh7aTBAQtOwp/eYHIPHom2Vl4E= MIME-Version: 1.0 Received: by 10.216.240.75 with SMTP id d53mr8823647wer.4.1288554253530; Sun, 31 Oct 2010 12:44:13 -0700 (PDT) Received: by 10.216.70.136 with HTTP; Sun, 31 Oct 2010 12:44:13 -0700 (PDT) Date: Sun, 31 Oct 2010 22:44:13 +0300 Message-ID: Subject: [PATCH 4/5] CIFS: New read logic From: Pavel Shilovsky To: linux-cifs@vger.kernel.org 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, 31 Oct 2010 19:44:15 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index e8b9523..21e0f47 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -570,6 +570,36 @@ cifs_get_sb(struct file_system_type *fs_type, return 0; } +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) { + int retval; + + retval = cifs_revalidate_file(iocb->ki_filp); + if (retval < 0) + return (loff_t)retval; + + return generic_file_aio_read(iocb, iov, nr_segs, pos); + } + + if (!CIFS_I(inode)->clientCanCacheRead) { + read = cifs_user_read(iocb->ki_filp, iov->iov_base, + iov->iov_len, &pos); + iocb->ki_pos = pos; + } else + read = generic_file_aio_read(iocb, iov, nr_segs, pos); + + return read; +} + static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { @@ -692,7 +722,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, @@ -729,7 +759,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,