From patchwork Mon Mar 31 07:28:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 3912681 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B1932BF540 for ; Mon, 31 Mar 2014 07:29:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED5DE20295 for ; Mon, 31 Mar 2014 07:29:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D7F020173 for ; Mon, 31 Mar 2014 07:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246AbaCaH3D (ORCPT ); Mon, 31 Mar 2014 03:29:03 -0400 Received: from mga09.intel.com ([134.134.136.24]:4290 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbaCaH3C (ORCPT ); Mon, 31 Mar 2014 03:29:02 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 31 Mar 2014 00:24:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,763,1389772800"; d="scan'208";a="483801521" Received: from zyan5-mobl.sh.intel.com ([10.239.13.16]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2014 00:29:00 -0700 From: "Yan, Zheng" To: fuse-devel@lists.sourceforge.net, ceph-devel@vger.kernel.org Cc: mszeredi@suse.cz, "Yan, Zheng" Subject: [PATCH] differentiate getattr that is for permission check Date: Mon, 31 Mar 2014 15:28:57 +0800 Message-Id: <1396250938-18904-1-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.8.5.3 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Introduce a new flag FUSE_GETATTR_PERM for getattr request. The flag indicates that the getattr request is for permission check. When getattr is for permission check, the user space daemon does not need to provide accurate size/ctime/mtime. This optimization is for Ceph fuse client. When a directory is accessed by multiple clients, getting accurate size/ctime/mtime of inode can be slow. Signed-off-by: Yan, Zheng --- include/fuse_common.h | 8 ++++++-- include/fuse_kernel.h | 1 + lib/fuse_lowlevel.c | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/fuse_common.h b/include/fuse_common.h index 22d9591..19cc13f 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -34,7 +34,7 @@ extern "C" { /** * Information about open files * - * Changed in version 3.0 + * Changed in version 3.1 */ struct fuse_file_info { /** Open flags. Available in open() and release() */ @@ -67,8 +67,12 @@ struct fuse_file_info { 2.9 */ unsigned int flock_release : 1; + /* Indicates that the getattr request is for inode permission + * check. Introduced in version 3.1 */ + unsigned int getattr_perm : 1; + /** Padding. Do not use*/ - unsigned int padding : 27; + unsigned int padding : 26; /** File handle. May be filled in by filesystem in open(). Available in all other file operations */ diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h index 7974721..a88d134 100644 --- a/include/fuse_kernel.h +++ b/include/fuse_kernel.h @@ -259,6 +259,7 @@ struct fuse_file_lock { * Getattr flags */ #define FUSE_GETATTR_FH (1 << 0) +#define FUSE_GETATTR_PERM (1 << 1) /** * Lock flags diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 4284535..8b203e7 100755 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1136,11 +1136,14 @@ static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) if (req->f->conn.proto_minor >= 9) { struct fuse_getattr_in *arg = (struct fuse_getattr_in *) inarg; - if (arg->getattr_flags & FUSE_GETATTR_FH) { + if (arg->getattr_flags) { memset(&fi, 0, sizeof(fi)); - fi.fh = arg->fh; fip = &fi; } + if (arg->getattr_flags & FUSE_GETATTR_FH) + fi.fh = arg->fh; + if (arg->getattr_flags & FUSE_GETATTR_PERM) + fi.getattr_perm = 1; } if (req->f->op.getattr)