From patchwork Mon Oct 5 11:02:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7326321 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 126739F1D5 for ; Mon, 5 Oct 2015 11:03:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C755206F8 for ; Mon, 5 Oct 2015 11:03:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A53E207BC for ; Mon, 5 Oct 2015 11:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751746AbbJELDC (ORCPT ); Mon, 5 Oct 2015 07:03:02 -0400 Received: from mail-qg0-f41.google.com ([209.85.192.41]:34207 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbbJELC5 (ORCPT ); Mon, 5 Oct 2015 07:02:57 -0400 Received: by qgez77 with SMTP id z77so146015329qge.1 for ; Mon, 05 Oct 2015 04:02:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PwTkspEGradr2Dn3ZORH2yuXd2fi92XnWwdOf6LNZPs=; b=Q87q7wqEIZJsyzRcPfHosd6dW75RhyHKu21srotmUtSaY0cSoD76zxUAZfeEpbqQP8 gHp7bXL1J/m5oiTnm5w+JLmBRiLGtz5zueQu/lGRg+ruoqmM2W5V6TPdC9jh6kDEYTsu 11RhDdXP5kuI0hJ0HH3kFxQRBGS3dxu8cC9Z5F37OmQx3k5Bx1wEcR1n4dzmWpdx6RUH tsPi1z/xl3x/Tj+BU3dva18HEmU6UBAekew4t9kX8rZaziuuYxUe7rppNzJrXEMBtVVO cCmJn9k4+CS8mjgwJIUX7I9hXblTiIaVAWsnnGp0R1B52JWSzKKvGu3ZkdbaH0pVk8fi P72g== X-Gm-Message-State: ALoCoQme6oxiETEq+mxBwF1GUMuCx2RVMJfcbEJI9/wskPH2A369dnuItMCMOvu7QXXhwlwFfBB9 X-Received: by 10.141.28.21 with SMTP id f21mr40766425qhe.13.1444042977393; Mon, 05 Oct 2015 04:02:57 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:6079::d5a]) by smtp.googlemail.com with ESMTPSA id p39sm4977719qkp.47.2015.10.05.04.02.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2015 04:02:56 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Al Viro Subject: [PATCH v5 09/20] sunrpc: add a new cache_detail operation for when a cache is flushed Date: Mon, 5 Oct 2015 07:02:31 -0400 Message-Id: <1444042962-6947-10-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444042962-6947-1-git-send-email-jeff.layton@primarydata.com> References: <1444042962-6947-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the exports table is changed, exportfs will usually write a new time to the "flush" file in the nfsd.export cache procfile. This tells the kernel to flush any entries that are older than that value. This gives us a mechanism to tell whether an unexport might have occurred. Add a new ->flush cache_detail operation that is called after flushing the cache whenever someone writes to a "flush" file. Signed-off-by: Jeff Layton --- include/linux/sunrpc/cache.h | 1 + net/sunrpc/cache.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 03d3b4c92d9f..d1c10a978bb2 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -98,6 +98,7 @@ struct cache_detail { int has_died); struct cache_head * (*alloc)(void); + void (*flush)(void); int (*match)(struct cache_head *orig, struct cache_head *new); void (*init)(struct cache_head *orig, struct cache_head *new); void (*update)(struct cache_head *orig, struct cache_head *new); diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 4a2340a54401..60da9aa2bdc5 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1451,6 +1451,9 @@ static ssize_t write_flush(struct file *file, const char __user *buf, cd->nextcheck = seconds_since_boot(); cache_flush(); + if (cd->flush) + cd->flush(); + *ppos += count; return count; }