diff options
author | Theodore Ts'o <tytso@mit.edu> | 2019-08-11 16:31:41 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2019-08-11 16:31:41 -0400 |
commit | 1ad3ea6e0a694b0486eb2cbe60378ad0fbf23642 (patch) | |
tree | b728b3450505eac1e85fb7898f49769a22a2938d | |
parent | b0c013e2928d3696ceb6401311dbc1d7fcccd6dd (diff) |
ext4: add a new ioctl EXT4_IOC_GETSTATE
The new ioctl EXT4_IOC_GETSTATE returns some of the dynamic state of
an ext4 inode for debugging purposes.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/ext4/ext4.h | 11 | ||||
-rw-r--r-- | fs/ext4/ioctl.c | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b22f24f1d365..ee296797bcd2 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -651,6 +651,7 @@ enum { | |||
651 | #define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY | 651 | #define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY |
652 | /* ioctl codes 19--39 are reserved for fscrypt */ | 652 | /* ioctl codes 19--39 are reserved for fscrypt */ |
653 | #define EXT4_IOC_CLEAR_ES_CACHE _IO('f', 40) | 653 | #define EXT4_IOC_CLEAR_ES_CACHE _IO('f', 40) |
654 | #define EXT4_IOC_GETSTATE _IOW('f', 41, __u32) | ||
654 | 655 | ||
655 | #define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR | 656 | #define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR |
656 | #define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR | 657 | #define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR |
@@ -664,6 +665,16 @@ enum { | |||
664 | #define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ | 665 | #define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ |
665 | #define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ | 666 | #define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ |
666 | 667 | ||
668 | /* | ||
669 | * Flags returned by EXT4_IOC_GETSTATE | ||
670 | * | ||
671 | * We only expose to userspace a subset of the state flags in | ||
672 | * i_state_flags | ||
673 | */ | ||
674 | #define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001 | ||
675 | #define EXT4_STATE_FLAG_NEW 0x00000002 | ||
676 | #define EXT4_STATE_FLAG_NEWENTRY 0x00000004 | ||
677 | #define EXT4_STATE_FLAG_DA_ALLOC_CLOSE 0x00000008 | ||
667 | 678 | ||
668 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | 679 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) |
669 | /* | 680 | /* |
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 15b1047878ab..ffb7bde4900d 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -1123,6 +1123,22 @@ resizefs_out: | |||
1123 | return 0; | 1123 | return 0; |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | case EXT4_IOC_GETSTATE: | ||
1127 | { | ||
1128 | __u32 state = 0; | ||
1129 | |||
1130 | if (ext4_test_inode_state(inode, EXT4_STATE_EXT_PRECACHED)) | ||
1131 | state |= EXT4_STATE_FLAG_EXT_PRECACHED; | ||
1132 | if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) | ||
1133 | state |= EXT4_STATE_FLAG_NEW; | ||
1134 | if (ext4_test_inode_state(inode, EXT4_STATE_NEWENTRY)) | ||
1135 | state |= EXT4_STATE_FLAG_NEWENTRY; | ||
1136 | if (ext4_test_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE)) | ||
1137 | state |= EXT4_STATE_FLAG_DA_ALLOC_CLOSE; | ||
1138 | |||
1139 | return put_user(state, (__u32 __user *) arg); | ||
1140 | } | ||
1141 | |||
1126 | case EXT4_IOC_FSGETXATTR: | 1142 | case EXT4_IOC_FSGETXATTR: |
1127 | { | 1143 | { |
1128 | struct fsxattr fa; | 1144 | struct fsxattr fa; |
@@ -1242,6 +1258,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1242 | case EXT4_IOC_SHUTDOWN: | 1258 | case EXT4_IOC_SHUTDOWN: |
1243 | case FS_IOC_GETFSMAP: | 1259 | case FS_IOC_GETFSMAP: |
1244 | case EXT4_IOC_CLEAR_ES_CACHE: | 1260 | case EXT4_IOC_CLEAR_ES_CACHE: |
1261 | case EXT4_IOC_GETSTATE: | ||
1245 | break; | 1262 | break; |
1246 | default: | 1263 | default: |
1247 | return -ENOIOCTLCMD; | 1264 | return -ENOIOCTLCMD; |