From patchwork Thu Feb 4 07:28:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1435850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=h+FH8S+d; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4DWVZC6d6qz9sVn for ; Thu, 4 Feb 2021 18:30:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232941AbhBDH3t (ORCPT ); Thu, 4 Feb 2021 02:29:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234397AbhBDH3n (ORCPT ); Thu, 4 Feb 2021 02:29:43 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B31AC061573; Wed, 3 Feb 2021 23:29:03 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id f1so3092037lfu.3; Wed, 03 Feb 2021 23:29:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=XTW6XCLvu1Ll2k8vkPwt+sB3B3vlqjNFERMspX4Qlhc=; b=h+FH8S+d2uHTg5TZ56C+GddfMlFudvAtGSOlJrwRI686KZHBEy3YjszukFMn3UbQYX IOr9wwuEC0QENX6iRIRYitvS/CjmbY1Qt2IUgcjBt1zzIzAIy8GDuw+yF8PUuim+0Lzv GvP1fM9yLAiBdaNO6ajl+kgu5xbpiULRFB03jRVL/+rIe8dYc9eIegooC0xbxrFjjPec u1PSd4TJDetKi03YSVtjnSDqDZU5PInaGTWfdXaNG0WYEroB2uCXYzIYyN+x6BVOgg+O e1hhlUc8BRymveSUrCH/xLPWWsL+++S8K1LVOP2kIK27+ywtioBssnN6DxWmTKP1U925 SOPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=XTW6XCLvu1Ll2k8vkPwt+sB3B3vlqjNFERMspX4Qlhc=; b=mDNysx6m08LeLbdi4kVxPWZn3ZuwRE6qxSzllnbJumEeVXWiuk4qj74w2eveW0FV47 EtJe28d1qVyWtFqe4H8TLg8svlt5nz3M1HRwSE6xCOgnJi0+VxrVcoNIrUZyxkuE+wl/ nJJEMXqRk7XxHsoCZT6oO9DfFWCxM4M70UJbudgInL+OU0blG9Is0dxzoZH3MkrjFo+C 6XpZWvyxto61HlHsH7AosC/9ElWryoGTZekiuBTTipFqHHUDTTWZFd9rfMV5rNrssQ/I HmVBYZp/e1eaRvt5kSj9b7iu+ngZXYOXgVkn23RKf1XeFmppPX2VVejUAtJMa9R+0pdP sfZg== X-Gm-Message-State: AOAM533dUuykcon53iZWNJf3tVN/b4NG3w2PgzOE/38Hg23C+Naovzaf ucI4hMOrwQLmkCQsDDgZn/Hx8x/lB5nxRl1ikLVdL/hVYQotlA== X-Google-Smtp-Source: ABdhPJwNe5DjZP/tZNFGYcoB1VdvGXCsEtlBN2qb+JzjpsNr008jQ+DIEngdRsUHWD/ndkF43QjOfQUuNEZVnCTdOR4= X-Received: by 2002:a05:6512:1311:: with SMTP id x17mr3920249lfu.307.1612423741679; Wed, 03 Feb 2021 23:29:01 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Thu, 4 Feb 2021 01:28:50 -0600 Message-ID: Subject: [PATCH] cifs: add new helper function for fscache conversion To: CIFS Cc: linux-fsdevel , David Howells Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Add new helper to check if fscache enabled for cifs inode Signed-off-by: David Howells Signed-off-by: Steve French --- fs/cifs/file.c | 7 +++++++ fs/cifs/fscache.h | 5 +++++ 2 files changed, 12 insertions(+) extern int __cifs_readpage_from_fscache(struct inode *, struct page *); @@ -138,6 +142,7 @@ static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {} static inline void cifs_fscache_set_inode_cookie(struct inode *inode, struct file *filp) {} static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {} +static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode) { return NULL; } static inline int cifs_fscache_release_page(struct page *page, gfp_t gfp) { return 1; /* May release page */ From 0f9488f68edbaf63db9f56e241d038685921630d Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Feb 2021 01:23:04 -0600 Subject: [PATCH] cifs: add new helper function for fscache conversion Add new helper to check if fscache enabled for cifs inode Signed-off-by: David Howells Signed-off-by: Steve French --- fs/cifs/file.c | 7 +++++++ fs/cifs/fscache.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 4b8c1ac58f00..49e7cf701b3e 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -4287,6 +4287,13 @@ cifs_readpages_copy_into_pages(struct TCP_Server_Info *server, return readpages_fill_pages(server, rdata, iter, iter->count); } +static bool cifs_is_cache_enabled(struct inode *inode) +{ + struct fscache_cookie *cookie = cifs_inode_cookie(inode); + + return fscache_cookie_enabled(cookie) && !hlist_empty(&cookie->backing_objects); +} + static int readpages_get_pages(struct address_space *mapping, struct list_head *page_list, unsigned int rsize, struct list_head *tmplist, diff --git a/fs/cifs/fscache.h b/fs/cifs/fscache.h index e811f2dd7619..713c0da1bad0 100644 --- a/fs/cifs/fscache.h +++ b/fs/cifs/fscache.h @@ -70,6 +70,10 @@ extern void cifs_fscache_release_inode_cookie(struct inode *); extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *); extern void cifs_fscache_reset_inode_cookie(struct inode *); +static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode) +{ + return CIFS_I(inode)->fscache; +} extern void __cifs_fscache_invalidate_page(struct page *, struct inode *); extern int cifs_fscache_release_page(struct page *page, gfp_t gfp); extern int __cifs_readpage_from_fscache(struct inode *, struct page *); @@ -138,6 +142,7 @@ static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {} static inline void cifs_fscache_set_inode_cookie(struct inode *inode, struct file *filp) {} static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {} +static inline struct fscache_cookie *cifs_inode_cookie(struct inode *inode) { return NULL; } static inline int cifs_fscache_release_page(struct page *page, gfp_t gfp) { return 1; /* May release page */ -- 2.27.0