Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbcKRDaH (ORCPT ); Thu, 17 Nov 2016 22:30:07 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:36677 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbcKRDaE (ORCPT ); Thu, 17 Nov 2016 22:30:04 -0500 Subject: Re: [PATCH 2/4] statx: Ext4: Return enhanced file attributes Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_21B94B40-CF13-4E6E-B929-A8076123A8C4"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Pgp-Agent: GPGMail From: Andreas Dilger In-Reply-To: <147938971095.13574.11430139440468763433.stgit@warthog.procyon.org.uk> Date: Thu, 17 Nov 2016 20:30:54 -0700 Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <1D78392E-B45A-4B06-A717-A5FB97806C94@dilger.ca> References: <147938969703.13574.10295364502230379833.stgit@warthog.procyon.org.uk> <147938971095.13574.11430139440468763433.stgit@warthog.procyon.org.uk> To: David Howells X-Mailer: Apple Mail (2.3124) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7460 Lines: 228 --Apple-Mail=_21B94B40-CF13-4E6E-B929-A8076123A8C4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Nov 17, 2016, at 6:35 AM, David Howells wrote: >=20 > Return enhanced file attributes from the Ext4 filesystem. This = includes > the following: >=20 > (1) The inode creation time (i_crtime) as stx_btime, setting = STATX_BTIME. >=20 > (2) The inode i_version as stx_version if a file with I_VERSION set or = a > directory, setting STATX_VERSION. >=20 > (3) Certain FS_xxx_FL flags are copied to stx_attribute flags. >=20 >=20 > This requires that all ext4 inodes have a getattr call, not just some = of > them, so to this end, split the ext4_getattr() function and only call = part > of it where appropriate. >=20 > Example output: >=20 > [root@andromeda ~]# touch foo > [root@andromeda ~]# chattr +ai foo > [root@andromeda ~]# /tmp/test-statx foo > statx(foo) =3D 0 > results=3Dfff > Size: 0 Blocks: 0 IO Block: 4096 = regular file > Device: 08:12 Inode: 2101950 Links: 1 > Access: (0644/-rw-r--r--) Uid: 0 Gid: 0 > Access: 2016-02-11 17:08:29.031795451+0000 > Modify: 2016-02-11 17:08:29.031795451+0000 > Change: 2016-02-11 17:11:11.987790114+0000 > Birth: 2016-02-11 17:08:29.031795451+0000 > Attributes: 0000000000000030 (-------- -------- -------- = -------- -------- -------- -------- --ai----) > IO-blocksize: blksize=3D4096 >=20 > Signed-off-by: David Howells Reviewed-by: Andreas Dilger > --- >=20 > fs/ext4/ext4.h | 2 ++ > fs/ext4/file.c | 2 +- > fs/ext4/inode.c | 38 +++++++++++++++++++++++++++++++++++--- > fs/ext4/namei.c | 2 ++ > fs/ext4/symlink.c | 2 ++ > 5 files changed, 42 insertions(+), 4 deletions(-) >=20 > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index 282a51b07c57..f65e4a560c4c 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -2485,6 +2485,8 @@ extern int ext4_getattr(struct vfsmount *mnt, = struct dentry *dentry, > struct kstat *stat); > extern void ext4_evict_inode(struct inode *); > extern void ext4_clear_inode(struct inode *); > +extern int ext4_file_getattr(struct vfsmount *mnt, struct dentry = *dentry, > + struct kstat *stat); > extern int ext4_sync_inode(handle_t *, struct inode *); > extern void ext4_dirty_inode(struct inode *, int); > extern int ext4_change_inode_journal_flag(struct inode *, int); > diff --git a/fs/ext4/file.c b/fs/ext4/file.c > index 2a822d30e73f..20bab4b0d6fc 100644 > --- a/fs/ext4/file.c > +++ b/fs/ext4/file.c > @@ -705,7 +705,7 @@ const struct file_operations ext4_file_operations = =3D { >=20 > const struct inode_operations ext4_file_inode_operations =3D { > .setattr =3D ext4_setattr, > - .getattr =3D ext4_getattr, > + .getattr =3D ext4_file_getattr, > .listxattr =3D ext4_listxattr, > .get_acl =3D ext4_get_acl, > .set_acl =3D ext4_set_acl, > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 9c064727ed62..91a49cbc4c63 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -5229,11 +5229,43 @@ int ext4_setattr(struct dentry *dentry, struct = iattr *attr) > int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, > struct kstat *stat) > { > - struct inode *inode; > - unsigned long long delalloc_blocks; > + struct inode *inode =3D d_inode(dentry); > + struct ext4_inode *raw_inode; > + struct ext4_inode_info *ei =3D EXT4_I(inode); > + unsigned int flags; > + > + if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) { > + stat->result_mask |=3D STATX_BTIME; > + stat->btime.tv_sec =3D ei->i_crtime.tv_sec; > + stat->btime.tv_nsec =3D ei->i_crtime.tv_nsec; > + } > + > + if (S_ISDIR(inode->i_mode) || IS_I_VERSION(inode)) { > + stat->result_mask |=3D STATX_VERSION; > + stat->version =3D inode->i_version; > + } > + > + ext4_get_inode_flags(ei); > + flags =3D ei->i_flags & EXT4_FL_USER_VISIBLE; > + stat->attributes |=3D flags & (EXT4_IMMUTABLE_FL | = EXT4_NODUMP_FL); > + if (flags & EXT4_APPEND_FL) > + stat->attributes |=3D STATX_ATTR_APPEND; > + if (flags & EXT4_COMPR_FL) > + stat->attributes |=3D STATX_ATTR_COMPRESSED; > + if (flags & EXT4_ENCRYPT_FL) > + stat->attributes |=3D STATX_ATTR_ENCRYPTED; >=20 > - inode =3D d_inode(dentry); > generic_fillattr(inode, stat); > + return 0; > +} > + > +int ext4_file_getattr(struct vfsmount *mnt, struct dentry *dentry, > + struct kstat *stat) > +{ > + struct inode *inode =3D dentry->d_inode; > + u64 delalloc_blocks; > + > + ext4_getattr(mnt, dentry, stat); >=20 > /* > * If there is inline data in the inode, the inode will normally = not > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index 104f8bfba718..e115281fb8c5 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -3882,6 +3882,7 @@ const struct inode_operations = ext4_dir_inode_operations =3D { > .tmpfile =3D ext4_tmpfile, > .rename =3D ext4_rename2, > .setattr =3D ext4_setattr, > + .getattr =3D ext4_getattr, > .listxattr =3D ext4_listxattr, > .get_acl =3D ext4_get_acl, > .set_acl =3D ext4_set_acl, > @@ -3890,6 +3891,7 @@ const struct inode_operations = ext4_dir_inode_operations =3D { >=20 > const struct inode_operations ext4_special_inode_operations =3D { > .setattr =3D ext4_setattr, > + .getattr =3D ext4_getattr, > .listxattr =3D ext4_listxattr, > .get_acl =3D ext4_get_acl, > .set_acl =3D ext4_set_acl, > diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c > index 557b3b0d668c..209b833633e2 100644 > --- a/fs/ext4/symlink.c > +++ b/fs/ext4/symlink.c > @@ -93,6 +93,7 @@ const struct inode_operations = ext4_symlink_inode_operations =3D { > .readlink =3D generic_readlink, > .get_link =3D page_get_link, > .setattr =3D ext4_setattr, > + .getattr =3D ext4_getattr, > .listxattr =3D ext4_listxattr, > }; >=20 > @@ -100,5 +101,6 @@ const struct inode_operations = ext4_fast_symlink_inode_operations =3D { > .readlink =3D generic_readlink, > .get_link =3D simple_get_link, > .setattr =3D ext4_setattr, > + .getattr =3D ext4_getattr, > .listxattr =3D ext4_listxattr, > }; >=20 > -- > To unsubscribe from this list: send the line "unsubscribe = linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Cheers, Andreas --Apple-Mail=_21B94B40-CF13-4E6E-B929-A8076123A8C4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIVAwUBWC517nKl2rkXzB/gAQg2DxAAibOnz+HkGbNqfZwFCexhlYOsQ1E4TMTz wWrCz+2xhc3C8Wm0reaqL4+BeZNzReBj9TMVYgUFbZsLkLTMlGrTdr45PDb4xmK4 DI85bdYQ6YeyY+198xWuOi7dnNrVyO2OBSLJsuR9XL1xNiTCuKX+2pRfLUKqI6pr Vs3x4qrKb+3ptngkn99c3xTXTRuks90HBldUBf0/1HPcDUiEiu6xQPKNtw5x4KsE XRaSSxaRsZPNTNNqBBchxHbgY/z7KhHHUUzlwkIVYsEdVdVapMcI+RzK07nzPnt2 BByz1UQs8t2ecPa0k1HatvU1XoWpCnXeimOp0Suu2OOXnwwy+4xADamDmzOGfI5i xSNxnVNCzKYd+IOvSH5wXlMXvfTGkE2T20BQbAY4eZrUzfIR/uw0Cwqcj/imYngD FSRawI5y8v1E8INvSf4hVF4SA/+SLvnG/d7QRDlLJMZoLWVlYpC4yMED/C9wTyaQ mT6BlWUgaeyBsuqDQ3evDqwNGu7MYFT/OIn3+Sa1+gdYZ/Z0LvVWUkZEvuYCWF0b 0+MIqd5Kcp3CcNjYe138TPXUWwIpgmYE554JWVw8jF6Po5Ve7vwlIFfqAaYK+78t KgxfxHdDnLu0woJ7OfXh7Xbm8BWoDGmxg3ebvcawXYsENF3XUR8Bvuqz9UDytpNu vHVwNEEvZ4Y= =eqTH -----END PGP SIGNATURE----- --Apple-Mail=_21B94B40-CF13-4E6E-B929-A8076123A8C4--