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: 7326351 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A405BBEEA4 for ; Mon, 5 Oct 2015 11:03:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3ACC206EB for ; Mon, 5 Oct 2015 11:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8D26206E9 for ; Mon, 5 Oct 2015 11:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751744AbbJELDC (ORCPT ); Mon, 5 Oct 2015 07:03:02 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:35651 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751540AbbJELC6 (ORCPT ); Mon, 5 Oct 2015 07:02:58 -0400 Received: by qgt47 with SMTP id 47so145706655qgt.2 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=TbnPekGJ5Yn7Oc2YWhZOaRZK9Mcpi4qBUx18r7Xa5ctzxG/CuyisMKUKoL0Bmo1Wgj 53m6b56rI/UoUQCTfQF2/5KI80F6zSXBgX4+U47j8OI0ER5AShFwCadfg08z9NrNxU37 BeGxakZHlzF2Nmh44bHn9/V/LTpHbhhAhUuzrs37oqLGpqIOv/c0/3332DZdKeCVcLT5 xXJp0EFgkSFTz5ib5RrFvb1/+oRNRdi0FYbj9coogxh8xf3s4MoxXsqom4+JhMYMei7c ++DTowHjPb2ai9oHpe5NG/e7y42pY3/uObfOjr12loIHz6R+9w2NO3cK6IMlULUx69+U ufPA== X-Gm-Message-State: ALoCoQlk+8Gl7PR0lpaM8EcohCEUnxcYrn/9ffWXhCK2otgWEzLFxU2mHomvrwH064Ymp80qE3cN 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-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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; }