From patchwork Tue Oct 26 13:03:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 282332 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 o9QD3RYU022764 for ; Tue, 26 Oct 2010 13:03:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759875Ab0JZNDN (ORCPT ); Tue, 26 Oct 2010 09:03:13 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:48447 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759864Ab0JZNDK (ORCPT ); Tue, 26 Oct 2010 09:03:10 -0400 Received: by qwk3 with SMTP id 3so2511807qwk.19 for ; Tue, 26 Oct 2010 06:03:10 -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=spBalmT4dYjErFSRnc5D4/2I1M/Fj87IQ7QovtU/5Kc=; b=lcPzEdyTHnHfvQFjjSO7pnHTq/T/7RSNcJQWicKAW2Q5i0MaK7AYLgD+wWiq3jnKFl apDBm2sxzSBixvO1pShE7KLLpn3SnDaJc89st8lijwrEXozuDYlHsbJ+VVF1A6ijqLMU zzAJbePCzA0NU6Ma+rcEFaCu4RFq40nwvTAzY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=E7OgdkggHE+YzkE+SggUO3S/sN19YrAnUitFUlMjg+T8G5a0bfHXWXAcnEa2ZNt2FZ Gs53pvravI6KVrgQE5QHz8ky28bTqnIqF4yi6QCfO2dn6nLsyq620W5APMdn+AKyAdkB Ts/w3lOJxuw3W5ovJiz4zB9pmnedM98TCdWWU= MIME-Version: 1.0 Received: by 10.224.191.129 with SMTP id dm1mr1161612qab.31.1288098190338; Tue, 26 Oct 2010 06:03:10 -0700 (PDT) Received: by 10.229.19.193 with HTTP; Tue, 26 Oct 2010 06:03:10 -0700 (PDT) Date: Tue, 26 Oct 2010 17:03:10 +0400 Message-ID: Subject: [PATCH 3/4] 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, 26 Oct 2010 13:03:28 +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,