Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1396529ybh; Sun, 19 Jul 2020 18:48:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMAUcZT3Craym/mpjPS+vRAqvyhgVu/PcKlrkFnUOsLUed5YDErKj+8HBaE+4Kju/FLCT9 X-Received: by 2002:a50:cd53:: with SMTP id d19mr19820243edj.300.1595209705065; Sun, 19 Jul 2020 18:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595209705; cv=none; d=google.com; s=arc-20160816; b=Vg2xuLyAeF3NWl77D4M8C9vNBM30f8cgcBjNwOXj/JNNmhRhEfDwLQIp1rfdircF/x /NyZNzAaw2jP9Hr2/Z2kzo7jJcVWgOTBHzIwnlzzSw4uAlxAHaZbTe8pTYl1IS3MhUFh 0HCcRxwnz4q3yXV9bb6IxY9awdPiG6xF+f35MXhIg1+YoJ5C4M9Y3xwqTjDuBZiQFeq9 wK6MLPOeR+FMfMKzzhY2y3sDa5zbNFGYXD0d89Ej3dBYaOP4STRCSIaaPvrp/5lD7q2F biL11yFgI28JMDse/oaR3iOzCAoUFoaQfLqo6gNsbF3uZrrk3opKIlU1DqAzZ28TWTbI whfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=aZ9GiExZW3QkniI9rzQ6OJi5UzrpNK8QDOpkq2ajCRw=; b=kuahf+hlbowW78/I9m1Pe3z4VB1qBbiLL+jC5ekCDTPLwP6LlchDhxT+wdpvatKjkC IpoJzvbJekwgizJEJidG5wFbpaxaeJaRGB+EhXXDDS3XCyDl1XhoailPK+ifLNFp5Sa8 ENHXe/JZVAlYy8oAdmoIJecRXYy3Q7BSmITrrBG+v6u2TZLd14I3jJc+OlfHaOobivAc bUSJtp1xgOt6BDWnXMSBp29kT2pxK26xPTkfgNkg2M/CfBKgICPmjmrtX5uLgkGt5uuI pAEr1W5Qt+CSvIxmfRFnXwc06LMPlF/jn9ZVv2CvH8BB5dRDitmmWyrIhUSZDJBfd9yR 1LTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si9753207ejo.44.2020.07.19.18.48.02; Sun, 19 Jul 2020 18:48:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbgGTBqi (ORCPT + 99 others); Sun, 19 Jul 2020 21:46:38 -0400 Received: from foss.arm.com ([217.140.110.172]:40810 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbgGTBqi (ORCPT ); Sun, 19 Jul 2020 21:46:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DAE8F12FC; Sun, 19 Jul 2020 18:46:37 -0700 (PDT) Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 79D6C3F66E; Sun, 19 Jul 2020 18:46:34 -0700 (PDT) From: Jianyong Wu To: ericvh@gmail.com, hch@lst.de, dhowells@redhat.com, lucho@ionkov.net, asmadeus@codewreck.org Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kaly.Xin@arm.com, justin.he@arm.com, jianyong.wu@arm.com, wei.chen@arm.com Subject: [RFC PATCH 1/2] vfs: pass file down when getattr to avoid losing info. Date: Mon, 20 Jul 2020 09:46:21 +0800 Message-Id: <20200720014622.37364-2-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200720014622.37364-1-jianyong.wu@arm.com> References: <20200720014622.37364-1-jianyong.wu@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, getting attribute for a file represented by fd is always by inode or path which may lead to bug for a certain network file system. Adding file struct into struct kstat and assigning file for it in vfs_statx_fd can avoid this issue. This change refers to struct istat. Signed-off-by: Jianyong Wu --- fs/stat.c | 1 + include/linux/stat.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/fs/stat.c b/fs/stat.c index 44f8ad346db4..0dee5487f6d6 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -147,6 +147,7 @@ int vfs_statx_fd(unsigned int fd, struct kstat *stat, return -EINVAL; f = fdget_raw(fd); + stat->filp = f.file; if (f.file) { error = vfs_getattr(&f.file->f_path, stat, request_mask, query_flags); diff --git a/include/linux/stat.h b/include/linux/stat.h index 56614af83d4a..4755c528d49a 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -48,6 +48,12 @@ struct kstat { struct timespec64 btime; /* File creation time */ u64 blocks; u64 mnt_id; + + /* + * Not an attribute, but an auxiliary info for filesystems wanting to + * implement an fstat() like method. + */ + struct file *filp; }; #endif -- 2.17.1