vfs: support STATX_DIOALIGN on block devices
[linux-block.git] / fs / stat.c
index a7930d74448304e29865ea49302dbffbea43191c..ef50573c72a2692908d5ad8bcd68e9a09e501c78 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -5,6 +5,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/blkdev.h>
 #include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
@@ -230,11 +231,22 @@ retry:
                goto out;
 
        error = vfs_getattr(&path, stat, request_mask, flags);
+
        stat->mnt_id = real_mount(path.mnt)->mnt_id;
        stat->result_mask |= STATX_MNT_ID;
+
        if (path.mnt->mnt_root == path.dentry)
                stat->attributes |= STATX_ATTR_MOUNT_ROOT;
        stat->attributes_mask |= STATX_ATTR_MOUNT_ROOT;
+
+       /* Handle STATX_DIOALIGN for block devices. */
+       if (request_mask & STATX_DIOALIGN) {
+               struct inode *inode = d_backing_inode(path.dentry);
+
+               if (S_ISBLK(inode->i_mode))
+                       bdev_statx_dioalign(inode, stat);
+       }
+
        path_put(&path);
        if (retry_estale(error, lookup_flags)) {
                lookup_flags |= LOOKUP_REVAL;