From patchwork Wed Aug 5 21:13:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 6953071 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 78A169F402 for ; Wed, 5 Aug 2015 21:13:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CF88204FF for ; Wed, 5 Aug 2015 21:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEB30204AB for ; Wed, 5 Aug 2015 21:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbbHEVNu (ORCPT ); Wed, 5 Aug 2015 17:13:50 -0400 Received: from mail-yk0-f169.google.com ([209.85.160.169]:36549 "EHLO mail-yk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbbHEVNs (ORCPT ); Wed, 5 Aug 2015 17:13:48 -0400 Received: by ykeo23 with SMTP id o23so46444389yke.3 for ; Wed, 05 Aug 2015 14:13:48 -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=N9uYtKxINe7H7GCB7oVD/9xW0Iikx42M9RH/AH9OMi+NGNFF/xFvf3sgXsdf1nK10B SyUVqrrtSxUz+yqcrtgUjVrVCalSB1pZqmJmQV21nSmqC6DmTua9v/AtvYfNrn4yCNvr jqQ3HNaaAKcxYlsR/bhm3m4eP2Jl5jlX8IUtS0p/96b87fiDJ6469B8m71v7yLXKVpTt tyTgXkGHFTLY1XP1gpdwKjat8+wGhs8V8wmEM3z4w0mvASLihncFPGwZgCP6jCxxBmNY bIR84h2uKSs8ryvMNGLJh9PXl56yKqhAhSR8ZikPrOIZHrZTEsZStixOyoQaJFMbnBpZ 4aOQ== X-Gm-Message-State: ALoCoQnKToK1kesrYIgHmCpQe+JolELVJss9MKJ+cEA9E82Dly97rOJ6UuKFPS1unRe9yWfY/F2A X-Received: by 10.129.35.14 with SMTP id j14mr11507299ywj.43.1438809228314; Wed, 05 Aug 2015 14:13:48 -0700 (PDT) Received: from tlielax.poochiereds.net (cpe-45-37-211-243.nc.res.rr.com. [45.37.211.243]) by smtp.googlemail.com with ESMTPSA id p81sm3975306ywe.19.2015.08.05.14.13.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 14:13:47 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 07/18] sunrpc: add a new cache_detail operation for when a cache is flushed Date: Wed, 5 Aug 2015 17:13:25 -0400 Message-Id: <1438809216-4846-8-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1438809216-4846-1-git-send-email-jeff.layton@primarydata.com> References: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> <1438809216-4846-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=-7.0 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; }