From patchwork Tue Nov 2 09:01:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 296852 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 oA291cqK015353 for ; Tue, 2 Nov 2010 09:01:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752417Ab0KBJB4 (ORCPT ); Tue, 2 Nov 2010 05:01:56 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:58959 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752407Ab0KBJBz (ORCPT ); Tue, 2 Nov 2010 05:01:55 -0400 Received: by wwe15 with SMTP id 15so7092120wwe.1 for ; Tue, 02 Nov 2010 02:01:54 -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=A9Aji3dBTgn22XfWmby8RMJAMa79ppKf4DQinCOlDO0=; b=j+sTiiL25dY3CMHYUCLJ7gUOvdBsaAiUewKTCM1+WlKOfcP3L8tLefCHI8W3iM3lVH IOrmRSd2i8BbT86JcyAK2chqXzetPAlIWs9yxMQ62YlU2LRwpRwIJQPKIeDGbxDyu7XF RUQb4Wl2HYj+gGE8tQPMtYb49hJuw8sU3EXwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Y4pY7LcLTUc5WQxHpyy1SM6jbkIU0pPqX4+HDQyyz43qum/+Kljv7bGjSxfnt3CbCt f13xsvbFvWwvfDUekZsCufZ26AKzw4orI5AeB3bwMmtHwDQ++P3bQuUpgXNWmP20C+cZ Xv5x7sj6L3DgOl2fYtslxI91aaASqZbciSVAA= MIME-Version: 1.0 Received: by 10.216.240.75 with SMTP id d53mr189919wer.4.1288688514315; Tue, 02 Nov 2010 02:01:54 -0700 (PDT) Received: by 10.216.70.136 with HTTP; Tue, 2 Nov 2010 02:01:54 -0700 (PDT) Date: Tue, 2 Nov 2010 12:01:54 +0300 Message-ID: Subject: [PATCH 3/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]); Tue, 02 Nov 2010 09:01:56 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 75c4eaa..1b44a92 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -569,6 +569,36 @@ 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) { + 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) { @@ -691,7 +721,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, @@ -728,7 +758,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,