Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1814979ybh; Mon, 20 Jul 2020 07:56:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZJFMZqEyYgm2XkcE5l6wXYTjyDPs8YIDyI42mFDKmMXfqROzrSb/F3Ea6NgEnlqMwQ6QC X-Received: by 2002:a17:906:7d86:: with SMTP id v6mr20626330ejo.542.1595256992539; Mon, 20 Jul 2020 07:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595256992; cv=none; d=google.com; s=arc-20160816; b=lQWDIKYQev4q6l5uYKKtVrdyXoko+ruMF2Kp112rnV3m5TSBzxrsyz3RQ8mphZrym4 0DDHG77uEf61+KAFqRXcOQ+9jOLJ2pmXnzZ6mXy+jQdzYTIXmirsip2eVV2fXuyV2bbG ZWmxJNNbL15bVhw+8lh7y/mCxu6flRl8y+xpT5nzro5H5Ar/rbu8B4lGXmo/3yI1Becz aINkycO10h6u/rkjjBV27ca4HztgjM5id8v2Uc5Uh0hhU04u876F0gHLLIOpRGQkLvW4 UA9CtkPBfFC1Pi1KQrnZrsDm8OoXVx4ERytRlnPaUixUIPLa3KlCOigqkBY3bsSee0KQ pjAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AVtjruzuxxV0+AW4gyj3g7ydxMD6NNMuP8iAGcgMqIE=; b=VzlDZKbGfa1QTrJIKs3kA2+BJkgiVp14UBE9HN8kfI+E6xJW54BI+IqwvVDMHiRHuu B+g5SNPMvcuTYOUxIKKBLz2m4Ip9SaSfLevEL1+KwLScPIIOHzVS7W/xML2v0FhSak/V v+u2J21ezr+9A9IHjQXrkAK/5RSBbxAH+1EzCcZwCwUdVz8VFB+qim8HoVtO43ToNrQP 9ywRepW1aZAKpT2Tf7/Fp6WsithuOqgRQ70eZkxYGfH7hVGgDbh/KiOTHhA/sJcA/q95 4GGAyumi/Fkci3p26dUjhBLHdgenby9CRb0MnmnehG5Hy6/L6NYWZmtsciXl+0VS+MFh 06Xg== 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 8si10417342edv.523.2020.07.20.07.56.08; Mon, 20 Jul 2020 07:56:32 -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 S1726899AbgGTOx7 (ORCPT + 99 others); Mon, 20 Jul 2020 10:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726601AbgGTOx6 (ORCPT ); Mon, 20 Jul 2020 10:53:58 -0400 Received: from nautica.notk.org (ipv6.notk.org [IPv6:2001:41d0:1:7a93::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC0A7C061794 for ; Mon, 20 Jul 2020 07:53:58 -0700 (PDT) Received: by nautica.notk.org (Postfix, from userid 1001) id C2768C009; Mon, 20 Jul 2020 16:53:55 +0200 (CEST) Date: Mon, 20 Jul 2020 16:53:40 +0200 From: Dominique Martinet To: Jianyong Wu Cc: ericvh@gmail.com, hch@lst.de, dhowells@redhat.com, lucho@ionkov.net, v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kaly.Xin@arm.com, justin.he@arm.com, wei.chen@arm.com Subject: Re: [RFC PATCH 1/2] vfs: pass file down when getattr to avoid losing info. Message-ID: <20200720145340.GA13275@nautica> References: <20200720014622.37364-1-jianyong.wu@arm.com> <20200720014622.37364-2-jianyong.wu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200720014622.37364-2-jianyong.wu@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jianyong Wu wrote on Mon, Jul 20, 2020: > 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; Just, no ; don't touch this, it isn't likely to get accepted ever. file operations should all have a filp around already, we need to fix this in our code. (also missing quite a few Cc if you ever want to touch these bits, at least linux-fsdevel@) FWIW the problem has been discussed a few times previously. I'd appreciate if you could take over from Eric and Greg's old series that intended to fix that: https://lore.kernel.org/lkml/146659832556.15781.17414806975641516683.stgit@bahia.lan/ it introduced a race somewhere, but the idea looked good at the time so it's worth looking into. -- Dominique