From patchwork Tue Oct 20 17:33:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 7449301 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 A6A149F1C3 for ; Tue, 20 Oct 2015 17:34:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9DC920842 for ; Tue, 20 Oct 2015 17:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED6B62083C for ; Tue, 20 Oct 2015 17:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbbJTReR (ORCPT ); Tue, 20 Oct 2015 13:34:17 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:35490 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753035AbbJTReG (ORCPT ); Tue, 20 Oct 2015 13:34:06 -0400 Received: by qkbl190 with SMTP id l190so10888224qkb.2 for ; Tue, 20 Oct 2015 10:34:05 -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=BA5y9ZZskz5VpvnFyAFtBuk6MiY8BXQ09axkLkvpLlBiixxCqL1rv29zd7fNtdFlAl BTNx5JEtEKRLYzej3iTBmTMi2HIrRr9El12eGeXeMy6Xm4cINDxnqJDsHxyGkzB26Th0 8+YeNC6UFk4DWdKVqFMzcCCjaEbLGdf3/UexomRNQnovTSDMKrQe7vCpJ1+5P4ZBrqge UEeIAlD+jZHldPI/OW2DpLQPfR859LMQnX003R9wLV2nCiNw1WVX3RI5D/z2idtAPoMl 0nD240sP4XuhwzgoKWzBc1YC/1WnbVGgPAQsArlPvGcqri5lZJkzU8Z3IoQQBHS1reKS VeCw== X-Gm-Message-State: ALoCoQmyV1jsgCSQXETtJItFXb8z0Oar6CEWbRFjXfp8mIeSp8HBTXrat8AEAIRWsxKojknZLiOi X-Received: by 10.55.197.88 with SMTP id p85mr5450925qki.44.1445362445526; Tue, 20 Oct 2015 10:34:05 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:6079::d5a]) by smtp.googlemail.com with ESMTPSA id m26sm1640925qki.28.2015.10.20.10.34.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 10:34:04 -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 v6 08/19] sunrpc: add a new cache_detail operation for when a cache is flushed Date: Tue, 20 Oct 2015 13:33:41 -0400 Message-Id: <1445362432-18869-9-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1445362432-18869-1-git-send-email-jeff.layton@primarydata.com> References: <1445362432-18869-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, 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; }