From patchwork Mon Sep 27 18:31: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: 213102 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 o8RIWCje031051 for ; Mon, 27 Sep 2010 18:32:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759986Ab0I0Sb4 (ORCPT ); Mon, 27 Sep 2010 14:31:56 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:43698 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759982Ab0I0Sbz (ORCPT ); Mon, 27 Sep 2010 14:31:55 -0400 Received: by qyk36 with SMTP id 36so5494841qyk.19 for ; Mon, 27 Sep 2010 11:31:55 -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=BXekbnB4wMAusyOhsv3UXFVt8/P4lhy/LuWTY4UBUOA=; b=X7wqp89mr5wiXIXj7gv5IuV0WS6tyUOwMMcXag2aL63ggzOY5v5jHbdcAcxVpgwBzY FCHmKTQuBV2c7cwOIflS2MqnLrKq3mEkpkAnkBnIYTGveNnbTEGZLigdZj1Fc+MlgmJK lJ3WJ7kC/q+Sugsx8MSkhQLvto3be5UdS00yU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=pB70JeGpWQklJYjg0qagHzfWoJdT/eOLl2JDpRa3Puz6WubcGxKp5CFPw6UrTOr5oy ajgWO6haYEeCcj3NAiBgR0XTD+bv4Avh5RBFPq8VUgmrQgVmIZfmgfML4a+HkEuCVzQ4 i/N4Vg/+IG5kEpwQQPzENK9jMb1UVNQGsshB0= MIME-Version: 1.0 Received: by 10.224.65.148 with SMTP id j20mr5772475qai.257.1285612314901; Mon, 27 Sep 2010 11:31:54 -0700 (PDT) Received: by 10.229.40.138 with HTTP; Mon, 27 Sep 2010 11:31:54 -0700 (PDT) Date: Mon, 27 Sep 2010 22:31:54 +0400 Message-ID: Subject: [PATCH 2/3] CIFS: New read cache mechanism 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]); Mon, 27 Sep 2010 18:32:12 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 898d2a5..a7361ee 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -549,6 +549,28 @@ cifs_get_sb(struct file_system_type *fs_type, return 0; } +static ssize_t cifs_sync_read(struct file *filp, char __user *buf, + size_t len, loff_t *ppos) +{ + ssize_t read; + struct cifsInodeInfo *cinode; + struct cifs_sb_info *cifs_sb; + + cifs_sb = CIFS_SB(filp->f_path.dentry->d_inode->i_sb); + + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)) + return do_sync_read(filp, buf, len, ppos); + + cinode = CIFS_I(filp->f_path.dentry->d_inode); + + if (cinode->clientCanCacheRead) + read = do_sync_read(filp, buf, len, ppos); + else + read = cifs_user_read(filp, buf, len, ppos); + + return read; +} + static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos) { @@ -668,7 +690,7 @@ const struct inode_operations cifs_symlink_inode_ops = { }; const struct file_operations cifs_file_ops = { - .read = do_sync_read, + .read = cifs_sync_read, .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = cifs_file_aio_write, @@ -705,7 +727,7 @@ const struct file_operations cifs_file_direct_ops = { .setlease = cifs_setlease, }; const struct file_operations cifs_file_nobrl_ops = { - .read = do_sync_read, + .read = cifs_sync_read, .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = cifs_file_aio_write,