From patchwork Mon Jul 5 12:43:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 110246 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o65ChO2B000427 for ; Mon, 5 Jul 2010 12:43:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758732Ab0GEMnY (ORCPT ); Mon, 5 Jul 2010 08:43:24 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:58822 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753790Ab0GEMnX (ORCPT ); Mon, 5 Jul 2010 08:43:23 -0400 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP; Mon, 05 Jul 2010 06:43:14 -0600 From: Suresh Jayaraman To: Steve French Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, David Howells Subject: [PATCH 07/09] cifs: store pages into local cache Date: Mon, 5 Jul 2010 18:13:11 +0530 Message-Id: <1278333791-30792-1-git-send-email-sjayaraman@suse.de> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: References: 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 (demeter.kernel.org [140.211.167.41]); Mon, 05 Jul 2010 12:43:24 +0000 (UTC) Index: cifs-2.6/fs/cifs/file.c =================================================================== --- cifs-2.6.orig/fs/cifs/file.c +++ cifs-2.6/fs/cifs/file.c @@ -1948,6 +1948,9 @@ static void cifs_copy_cache_pages(struct SetPageUptodate(page); unlock_page(page); data += PAGE_CACHE_SIZE; + + /* add page to FS-Cache */ + cifs_readpage_to_fscache(mapping->host, page); } return; } @@ -2117,6 +2120,10 @@ static int cifs_readpage_worker(struct f flush_dcache_page(page); SetPageUptodate(page); + + /* send this page to the cache */ + cifs_readpage_to_fscache(file->f_path.dentry->d_inode, page); + rc = 0; io_error: Index: cifs-2.6/fs/cifs/fscache.c =================================================================== --- cifs-2.6.orig/fs/cifs/fscache.c +++ cifs-2.6/fs/cifs/fscache.c @@ -140,6 +140,17 @@ int cifs_fscache_release_page(struct pag return 1; } +void __cifs_readpage_to_fscache(struct inode *inode, struct page *page) +{ + int ret; + + cFYI(1, "CIFS: readpage_to_fscache(fsc: %p, p: %p, i: %p", + CIFS_I(inode)->fscache, page, inode); + ret = fscache_write_page(CIFS_I(inode)->fscache, page, GFP_KERNEL); + if (ret != 0) + fscache_uncache_page(CIFS_I(inode)->fscache, page); +} + void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode) { struct cifsInodeInfo *cifsi = CIFS_I(inode); Index: cifs-2.6/fs/cifs/fscache.h =================================================================== --- cifs-2.6.orig/fs/cifs/fscache.h +++ cifs-2.6/fs/cifs/fscache.h @@ -51,6 +51,8 @@ extern void cifs_fscache_reset_inode_coo extern void __cifs_fscache_invalidate_page(struct page *, struct inode *); extern int cifs_fscache_release_page(struct page *page, gfp_t gfp); +extern void __cifs_readpage_to_fscache(struct inode *, struct page *); + static inline void cifs_fscache_invalidate_page(struct page *page, struct inode *inode) { @@ -58,6 +60,13 @@ static inline void cifs_fscache_invalida __cifs_fscache_invalidate_page(page, inode); } +static inline void cifs_readpage_to_fscache(struct inode *inode, + struct page *page) +{ + if (PageFsCache(page)) + __cifs_readpage_to_fscache(inode, page); +} + #else /* CONFIG_CIFS_FSCACHE */ static inline int cifs_fscache_register(void) { return 0; } static inline void cifs_fscache_unregister(void) {} @@ -81,6 +90,8 @@ static inline void cifs_fscache_release_ static inline int cifs_fscache_invalidate_page(struct page *page, struct inode *) {} +static inline void cifs_readpage_to_fscache(struct inode *inode, + struct page *page) {} #endif /* CONFIG_CIFS_FSCACHE */