diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-04-12 10:41:17 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-04-14 21:15:57 -0400 |
commit | c23232d409355091502a362e99ed06f800765961 (patch) | |
tree | d4b539e0b04a2089afe27f8e89c07f4b7c096261 /fs/xfs | |
parent | 7cd5006bdb6f6d9d9d7e68aa1d96b6e4a8b68bc5 (diff) |
xfs: report fs and rt health via geometry structure
Use our newly expanded geometry structure to report the overall fs and
realtime health status.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_fs.h | 11 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_health.h | 3 | ||||
-rw-r--r-- | fs/xfs/xfs_health.c | 56 | ||||
-rw-r--r-- | fs/xfs/xfs_ioctl.c | 5 |
4 files changed, 73 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index ee33d628a240..6b8956dbf49d 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h | |||
@@ -199,9 +199,18 @@ struct xfs_fsop_geom { | |||
199 | __u32 rtsectsize; /* realtime sector size, bytes */ | 199 | __u32 rtsectsize; /* realtime sector size, bytes */ |
200 | __u32 dirblocksize; /* directory block size, bytes */ | 200 | __u32 dirblocksize; /* directory block size, bytes */ |
201 | __u32 logsunit; /* log stripe unit, bytes */ | 201 | __u32 logsunit; /* log stripe unit, bytes */ |
202 | __u64 reserved[18]; /* reserved space */ | 202 | uint32_t sick; /* o: unhealthy fs & rt metadata */ |
203 | uint32_t checked; /* o: checked fs & rt metadata */ | ||
204 | __u64 reserved[17]; /* reserved space */ | ||
203 | }; | 205 | }; |
204 | 206 | ||
207 | #define XFS_FSOP_GEOM_SICK_COUNTERS (1 << 0) /* summary counters */ | ||
208 | #define XFS_FSOP_GEOM_SICK_UQUOTA (1 << 1) /* user quota */ | ||
209 | #define XFS_FSOP_GEOM_SICK_GQUOTA (1 << 2) /* group quota */ | ||
210 | #define XFS_FSOP_GEOM_SICK_PQUOTA (1 << 3) /* project quota */ | ||
211 | #define XFS_FSOP_GEOM_SICK_RT_BITMAP (1 << 4) /* realtime bitmap */ | ||
212 | #define XFS_FSOP_GEOM_SICK_RT_SUMMARY (1 << 5) /* realtime summary */ | ||
213 | |||
205 | /* Output for XFS_FS_COUNTS */ | 214 | /* Output for XFS_FS_COUNTS */ |
206 | typedef struct xfs_fsop_counts { | 215 | typedef struct xfs_fsop_counts { |
207 | __u64 freedata; /* free data section blocks */ | 216 | __u64 freedata; /* free data section blocks */ |
diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h index 0915d20975be..3fffdcc80970 100644 --- a/fs/xfs/libxfs/xfs_health.h +++ b/fs/xfs/libxfs/xfs_health.h | |||
@@ -34,6 +34,7 @@ | |||
34 | struct xfs_mount; | 34 | struct xfs_mount; |
35 | struct xfs_perag; | 35 | struct xfs_perag; |
36 | struct xfs_inode; | 36 | struct xfs_inode; |
37 | struct xfs_fsop_geom; | ||
37 | 38 | ||
38 | /* Observable health issues for metadata spanning the entire filesystem. */ | 39 | /* Observable health issues for metadata spanning the entire filesystem. */ |
39 | #define XFS_SICK_FS_COUNTERS (1 << 0) /* summary counters */ | 40 | #define XFS_SICK_FS_COUNTERS (1 << 0) /* summary counters */ |
@@ -182,4 +183,6 @@ xfs_inode_is_healthy(struct xfs_inode *ip) | |||
182 | return !xfs_inode_has_sickness(ip, -1U); | 183 | return !xfs_inode_has_sickness(ip, -1U); |
183 | } | 184 | } |
184 | 185 | ||
186 | void xfs_fsop_geom_health(struct xfs_mount *mp, struct xfs_fsop_geom *geo); | ||
187 | |||
185 | #endif /* __XFS_HEALTH_H__ */ | 188 | #endif /* __XFS_HEALTH_H__ */ |
diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c index 21728228e08b..d137b8f13869 100644 --- a/fs/xfs/xfs_health.c +++ b/fs/xfs/xfs_health.c | |||
@@ -264,3 +264,59 @@ xfs_inode_measure_sickness( | |||
264 | *checked = ip->i_checked; | 264 | *checked = ip->i_checked; |
265 | spin_unlock(&ip->i_flags_lock); | 265 | spin_unlock(&ip->i_flags_lock); |
266 | } | 266 | } |
267 | |||
268 | /* Mappings between internal sick masks and ioctl sick masks. */ | ||
269 | |||
270 | struct ioctl_sick_map { | ||
271 | unsigned int sick_mask; | ||
272 | unsigned int ioctl_mask; | ||
273 | }; | ||
274 | |||
275 | static const struct ioctl_sick_map fs_map[] = { | ||
276 | { XFS_SICK_FS_COUNTERS, XFS_FSOP_GEOM_SICK_COUNTERS}, | ||
277 | { XFS_SICK_FS_UQUOTA, XFS_FSOP_GEOM_SICK_UQUOTA }, | ||
278 | { XFS_SICK_FS_GQUOTA, XFS_FSOP_GEOM_SICK_GQUOTA }, | ||
279 | { XFS_SICK_FS_PQUOTA, XFS_FSOP_GEOM_SICK_PQUOTA }, | ||
280 | { 0, 0 }, | ||
281 | }; | ||
282 | |||
283 | static const struct ioctl_sick_map rt_map[] = { | ||
284 | { XFS_SICK_RT_BITMAP, XFS_FSOP_GEOM_SICK_RT_BITMAP }, | ||
285 | { XFS_SICK_RT_SUMMARY, XFS_FSOP_GEOM_SICK_RT_SUMMARY }, | ||
286 | { 0, 0 }, | ||
287 | }; | ||
288 | |||
289 | static inline void | ||
290 | xfgeo_health_tick( | ||
291 | struct xfs_fsop_geom *geo, | ||
292 | unsigned int sick, | ||
293 | unsigned int checked, | ||
294 | const struct ioctl_sick_map *m) | ||
295 | { | ||
296 | if (checked & m->sick_mask) | ||
297 | geo->checked |= m->ioctl_mask; | ||
298 | if (sick & m->sick_mask) | ||
299 | geo->sick |= m->ioctl_mask; | ||
300 | } | ||
301 | |||
302 | /* Fill out fs geometry health info. */ | ||
303 | void | ||
304 | xfs_fsop_geom_health( | ||
305 | struct xfs_mount *mp, | ||
306 | struct xfs_fsop_geom *geo) | ||
307 | { | ||
308 | const struct ioctl_sick_map *m; | ||
309 | unsigned int sick; | ||
310 | unsigned int checked; | ||
311 | |||
312 | geo->sick = 0; | ||
313 | geo->checked = 0; | ||
314 | |||
315 | xfs_fs_measure_sickness(mp, &sick, &checked); | ||
316 | for (m = fs_map; m->sick_mask; m++) | ||
317 | xfgeo_health_tick(geo, sick, checked, m); | ||
318 | |||
319 | xfs_rt_measure_sickness(mp, &sick, &checked); | ||
320 | for (m = rt_map; m->sick_mask; m++) | ||
321 | xfgeo_health_tick(geo, sick, checked, m); | ||
322 | } | ||
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index b36abd453709..ae615a79b266 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "scrub/xfs_scrub.h" | 34 | #include "scrub/xfs_scrub.h" |
35 | #include "xfs_sb.h" | 35 | #include "xfs_sb.h" |
36 | #include "xfs_ag.h" | 36 | #include "xfs_ag.h" |
37 | #include "xfs_health.h" | ||
37 | 38 | ||
38 | #include <linux/capability.h> | 39 | #include <linux/capability.h> |
39 | #include <linux/cred.h> | 40 | #include <linux/cred.h> |
@@ -797,8 +798,10 @@ xfs_ioc_fsgeometry( | |||
797 | len = sizeof(struct xfs_fsop_geom_v1); | 798 | len = sizeof(struct xfs_fsop_geom_v1); |
798 | else if (struct_version == 4) | 799 | else if (struct_version == 4) |
799 | len = sizeof(struct xfs_fsop_geom_v4); | 800 | len = sizeof(struct xfs_fsop_geom_v4); |
800 | else | 801 | else { |
802 | xfs_fsop_geom_health(mp, &fsgeo); | ||
801 | len = sizeof(fsgeo); | 803 | len = sizeof(fsgeo); |
804 | } | ||
802 | 805 | ||
803 | if (copy_to_user(arg, &fsgeo, len)) | 806 | if (copy_to_user(arg, &fsgeo, len)) |
804 | return -EFAULT; | 807 | return -EFAULT; |