Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3772918imm; Mon, 4 Jun 2018 09:01:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK1C0+xbXHT0WQ2ryytavf2DJr4QCwdY5O3p4TVRww1vUyGfPFZohAMzmMn2v0WVUlCNrdc X-Received: by 2002:a17:902:7293:: with SMTP id d19-v6mr5061973pll.142.1528128095703; Mon, 04 Jun 2018 09:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528128095; cv=none; d=google.com; s=arc-20160816; b=wuZpEvwW9+eAyV/2AYTA4ryVVH6Bxr+KZunp2Pmk+s/kXjZ0CqPoYz5ExxjPHO/NYo 2CvFAqhaKd8qPJIXKwyo1TOJRomd9H4Y48Nnc32nolYDHQsTOfIaGpBlWkYuYgx5DzEA OsnOQx6WHmxgniNJ1+seQnR08efieyBWFTcfFzCv5o0Uc1+8l44P+wthustKHR9bRNqJ zT8X6yGlb871aGZW9nKw0+P1SVcWFXpVniyr6bxyOMYY8T6vxGn1U3Wn5FOOG+rd0Bf1 Xkp4ivSTCvG+CHLUjPjpaz0Yu84vqU7PB89OGC6jHkBjdPcedCworZsI4X5bptWj3wDh XylA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=eJP3m9EE2p7IwAyoVNeGbd312JLXtu3jEoRFg9oHvxw=; b=LIoMI94MoiAmDQ4WP0iNF9HJZhBlo0lWVR8ECyi8Z+bMAip8ZdNQ6Cq/RTRzw23vln xjaBtjerWb2j1979r0xwXv0qa+tKcqQ1D5dYFnlV25y4AE/2CjviIi3F4g65o7Oqdu6M Wml2ANCU3EAaeXqXrOTZi6W7vg7G5568UEirqbXs8rrSnniqvGW7EQ6y3H4QqUs0thRL A/b+erz/ZYwPVOw2GJRynvOnMx+Qn+VLHD5oMk72r6GPGjpo9bs9YAX+Q51E/8mFjMRW X3J7v6y8BKdk9R791Iiv9+W1anMDger807s7+JIKdW25C8IwI/2JHRRNYgD+31xguiw7 GRlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uQQXbtmW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9-v6si36813540pgc.601.2018.06.04.09.01.20; Mon, 04 Jun 2018 09:01:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uQQXbtmW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751632AbeFDQAb (ORCPT + 99 others); Mon, 4 Jun 2018 12:00:31 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33094 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751385AbeFDQAa (ORCPT ); Mon, 4 Jun 2018 12:00:30 -0400 Received: by mail-lf0-f68.google.com with SMTP id y20-v6so26064102lfy.0; Mon, 04 Jun 2018 09:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=eJP3m9EE2p7IwAyoVNeGbd312JLXtu3jEoRFg9oHvxw=; b=uQQXbtmWkAr4DjHUOlmmW2VDkAwRrjGnfN6P8La0AFd/K89E+qhPzgw3LgTBE/Cnz2 vxoZgx5X8FC53/u42VuDrQbfprvF130/A1O0+hg8egeQCpxRjlQKCqPp7Y4upDfUKsqu dijvJErQ6SqgGbYGKoASnyI5oNyzhGeqSY6xdk03k7AqJmJmGldSS1iROwnGElys2fa+ OV6YLG1DE853cby7M7aQdQIL/yoKN+V5qQObv5sdmiJHFH3aQF5u8FllyXny8UguVjTf kJEyHFB5t+w34N4wNR/ku5DTv2MEBPmT/U8QZGzfg4n6MTQ6W7hmnO4Y9DT6mNyxVYK6 cOSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=eJP3m9EE2p7IwAyoVNeGbd312JLXtu3jEoRFg9oHvxw=; b=nD0hEb/amOfDb82WWrvXCv70APqu6VtmL/LglhY2MhoDvbEGDjKHeDikFm71e9E0pU cbFSCH0shnGAGLVM+TumHADUpGWryewBnrE/9/IhIqLf9EM9zwJbclhn9iy8ZcfgvAYS JNP+YnwfZvsqhg+UsWCYNrA3+S2jxLaPWLNPlHLXNWr8BkiVSwmLcnuMJdP9l291nbJZ uWCuVOr3iHwhYzCqQaaFYiXzAOzdHW92hL6WESCTy2tpo1OjVs+up9nlfQh5WgJ5gzT5 hrM6bYPxVpn6Le7uK6OrqGFxoam8K3qCFQYKO1mmNskfyK0ijHjvU1gCTqLk5Q1KsNVV lbiA== X-Gm-Message-State: ALKqPwfq5knxH4lBr2R217rTb0/RcuWdX1aJ6c+ku00P62lJAp85Oxee 5sFJblHgtfNJkT/RYWK7KPQB+27jXWLwpjZpz88= X-Received: by 2002:a2e:21c6:: with SMTP id h67-v6mr15193833lji.132.1528128028132; Mon, 04 Jun 2018 09:00:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:56c8:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 09:00:27 -0700 (PDT) In-Reply-To: <21648.1528124488@warthog.procyon.org.uk> References: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> <152720693123.9073.4511934790831409009.stgit@warthog.procyon.org.uk> <21648.1528124488@warthog.procyon.org.uk> From: Arnd Bergmann Date: Mon, 4 Jun 2018 18:00:27 +0200 X-Google-Sender-Auth: NT5EhOlX6bxl-8ISlcp5d2GUMFE Message-ID: Subject: Re: [PATCH 32/32] [RFC] fsinfo: Add a system call to allow querying of filesystem information [ver #8] To: David Howells Cc: Al Viro , Linux FS-devel Mailing List , linux-afs@lists.infradead.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 4, 2018 at 5:01 PM, David Howells wrote: > Arnd Bergmann wrote: > >> ntfs has sb->s_time_gran=100, and vfat should really have >> sb->s_time_gran=2000000000 but that doesn't seem to be set right >> at the moment. > > (V)FAT actually has a different granularity on each timestamp. Ah, right. I guess I missed the fact that the file system can override it, so FAT doesn't actually have to do it this way. >> > +struct fsinfo_capabilities { >> > + __u64 supported_stx_attributes; /* What statx::stx_attributes are supported */ >> > + __u32 supported_stx_mask; /* What statx::stx_mask bits are supported */ >> > + __u32 supported_ioc_flags; /* What FS_IOC_* flags are supported */ >> > + __u8 capabilities[(fsinfo_cap__nr + 7) / 8]; >> > +}; >> >> This looks a bit odd: with the 44 capabilities, you end up having a six-byte >> array followed by two bytes of implicit padding. If the number of >> capabilities grows beyond 64, you have a nine byte array with more padding >> to the next alignof(__u64). Is that intentional? > > I've split the capabilities out into their own thing. I've attached the > revised patch below. I'm still not completely clear on how variable-length structures are supposed to be handled by the fsinfo syscall. It seems like a possible source of bugs to return a structure from the kernel that has a different size in kernel and user space depending on the fsinfo_cap__nr value at compile time. How does one e.g. guarantee there is no out of bounds access when you run new user space on an older kernel that has a smaller structure? >> > +struct fsinfo_timestamp_info { >> > + __s64 minimum_timestamp; /* Minimum timestamp value in seconds */ >> > + __s64 maximum_timestamp; /* Maximum timestamp value in seconds */ >> > + __u16 atime_gran_mantissa; /* Granularity(secs) = mant * 10^exp */ >> > + __u16 btime_gran_mantissa; >> > + __u16 ctime_gran_mantissa; >> > + __u16 mtime_gran_mantissa; >> > + __s8 atime_gran_exponent; >> > + __s8 btime_gran_exponent; >> > + __s8 ctime_gran_exponent; >> > + __s8 mtime_gran_exponent; >> > +}; >> >> This structure has a slightly inconsistent amount of padding at the end: >> on x86-32 it has no padding, everywhere else it has 32 bits of padding >> to make it 64-bit aligned. Maybe add a __u32 reserved field? > > It occurs to me that the min and max may be different for each timestamp. > Maybe I should have: > > struct fsinfo_timestamp_info { > char name[7 + 1]; > __s64 minimum_timestamp; > __s64 maximum_timestamp; > __u16 granularity_mantissa; > __s8 granularity_exponent; > __u8 __reserved[5]; > }; > I don't particularly like having a string in there, that seems to add unnecessary complexity compared to using an integer. Having four min/max values would make it more generic but I don't think we have a need for that at the moment with any of the file systems we support. In any case, it would be nice to have a trivial way to query which of the four timestamp types are supported at all, and returning them separately would be one way of doing that. > and then you iterate through them by setting Nth. I could just put a: > > __u64 granularity; > > field, expressed in nS, rather than mantissa and exponent, but doing it this > way allows me to express granularities less that 1nS very simply (something > Dave Chinner was talking about). > > It might also be worth putting minimum_timestamp and maximum_timestamp in > terms of granularity rather than nS. Expressing the granularity in nanoseconds (or something smaller) would seem more natural to me, but I don't really care much either way. Arnd