From patchwork Thu Jul 30 13:52:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 6902811 Return-Path: X-Original-To: patchwork-linux-nfs@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 E01529F38B for ; Thu, 30 Jul 2015 13:52:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5995205B8 for ; Thu, 30 Jul 2015 13:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E05CB20592 for ; Thu, 30 Jul 2015 13:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753295AbbG3Nwm (ORCPT ); Thu, 30 Jul 2015 09:52:42 -0400 Received: from mail-yk0-f177.google.com ([209.85.160.177]:35571 "EHLO mail-yk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753345AbbG3Nwj (ORCPT ); Thu, 30 Jul 2015 09:52:39 -0400 Received: by ykdu72 with SMTP id u72so34300702ykd.2 for ; Thu, 30 Jul 2015 06:52:38 -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=dz7yb8a/fCd1MI22+itDxwG90S9XiV4qtXgcWNb7uxc=; b=jmD6AHuk1hdyC7/MFbw2Olwk812JVHMMmaU9f1XR/KT2ZTd339UMEE9dZJ2JYZ1GyW bzR+u0+W9+5SwvRhQDeWh+aYa8XAPmsoPcNMCxlIL0oILHzN+dZohcdBeU03Q8wfFCmL QkZJlfDb3uAiq3o5lOQ3DVi9457iWL5iMiOu7tC46zehQvl7XhrXALwutULaBOKh4pWn mszQeEglxoAy+kPcNR4gbA4FEboaxxcQMZ2PzjWGjGwGu4kyB+yn0w0ZoZwsnxHlYUsm ZmTNhJq+JH72oCvyVkG4sFRMsALDwpyiiympnsiNsdXtaC7DFrNsZk9uyDdh7TrXpjzg PkOA== X-Gm-Message-State: ALoCoQmq8T4oZU7+KxuGKbNv+XjSAu9xqYuLCD+wvRmuP+smQxcZ46Ip47cWX9TD67yA3ETozB9q X-Received: by 10.129.88.86 with SMTP id m83mr51845286ywb.147.1438264358597; Thu, 30 Jul 2015 06:52:38 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1105:8e:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id c184sm796301ywb.22.2015.07.30.06.52.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 06:52:38 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH 7/9] sunrpc: add a new cache_detail operation for when a cache is flushed Date: Thu, 30 Jul 2015 09:52:19 -0400 Message-Id: <1438264341-18048-9-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> References: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.3 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 437ddb6c4aef..29033421aa0c 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 2928afffbb81..19dc71ccc706 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1452,6 +1452,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; }