Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xfs: allow setting errortags at mount time

Add an errortag mount option that enables an errortag with the default
injection frequency. This allows injecting errors into the mount
process instead of just on live file systems, and thus test mount
error handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by

Christoph Hellwig and committed by
Carlos Maiolino
2d263deb 4d8f4246

+55 -1
+8
Documentation/admin-guide/xfs.rst
··· 215 215 inconsistent namespace presentation during or after a 216 216 failover event. 217 217 218 + errortag=tagname 219 + When specified, enables the error inject tag named "tagname" with the 220 + default frequency. Can be specified multiple times to enable multiple 221 + errortags. Specifying this option on remount will reset the error tag 222 + to the default value if it was set to any other value before. 223 + This option is only supported when CONFIG_XFS_DEBUG is enabled, and 224 + will not be reflected in /proc/self/mounts. 225 + 218 226 Deprecation of V4 Format 219 227 ======================== 220 228
+36
fs/xfs/xfs_error.c
··· 22 22 static const unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS }; 23 23 #undef XFS_ERRTAG 24 24 25 + #define XFS_ERRTAG(_tag, _name, _default) \ 26 + [XFS_ERRTAG_##_tag] = __stringify(_name), 27 + #include "xfs_errortag.h" 28 + static const char *xfs_errortag_names[] = { XFS_ERRTAGS }; 29 + #undef XFS_ERRTAG 30 + 25 31 struct xfs_errortag_attr { 26 32 struct attribute attr; 27 33 unsigned int tag; ··· 193 187 WRITE_ONCE(mp->m_errortag[error_tag], 194 188 xfs_errortag_random_default[error_tag]); 195 189 return 0; 190 + } 191 + 192 + int 193 + xfs_errortag_add_name( 194 + struct xfs_mount *mp, 195 + const char *tag_name) 196 + { 197 + unsigned int i; 198 + 199 + for (i = 0; i < XFS_ERRTAG_MAX; i++) { 200 + if (xfs_errortag_names[i] && 201 + !strcmp(xfs_errortag_names[i], tag_name)) 202 + return xfs_errortag_add(mp, i); 203 + } 204 + 205 + return -EINVAL; 206 + } 207 + 208 + void 209 + xfs_errortag_copy( 210 + struct xfs_mount *dst_mp, 211 + struct xfs_mount *src_mp) 212 + { 213 + unsigned int val, i; 214 + 215 + for (i = 0; i < XFS_ERRTAG_MAX; i++) { 216 + val = READ_ONCE(src_mp->m_errortag[i]); 217 + if (val) 218 + WRITE_ONCE(dst_mp->m_errortag[i], val); 219 + } 196 220 } 197 221 198 222 int
+4
fs/xfs/xfs_error.h
··· 45 45 #define XFS_ERRORTAG_DELAY(mp, tag) \ 46 46 xfs_errortag_delay((mp), __FILE__, __LINE__, (tag)) 47 47 int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); 48 + int xfs_errortag_add_name(struct xfs_mount *mp, const char *tag_name); 49 + void xfs_errortag_copy(struct xfs_mount *dst_mp, struct xfs_mount *src_mp); 48 50 int xfs_errortag_clearall(struct xfs_mount *mp); 49 51 #else 50 52 #define xfs_errortag_init(mp) (0) ··· 54 52 #define XFS_TEST_ERROR(mp, tag) (false) 55 53 #define XFS_ERRORTAG_DELAY(mp, tag) ((void)0) 56 54 #define xfs_errortag_add(mp, tag) (-ENOSYS) 55 + #define xfs_errortag_copy(dst_mp, src_mp) ((void)0) 56 + #define xfs_errortag_add_name(mp, tag_name) (-ENOSYS) 57 57 #define xfs_errortag_clearall(mp) (-ENOSYS) 58 58 #endif /* DEBUG */ 59 59
+7 -1
fs/xfs/xfs_super.c
··· 40 40 #include "xfs_defer.h" 41 41 #include "xfs_attr_item.h" 42 42 #include "xfs_xattr.h" 43 + #include "xfs_error.h" 43 44 #include "xfs_errortag.h" 44 45 #include "xfs_iunlink_item.h" 45 46 #include "xfs_dahash_test.h" ··· 115 114 Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota, 116 115 Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce, 117 116 Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum, Opt_max_open_zones, 118 - Opt_lifetime, Opt_nolifetime, Opt_max_atomic_write, 117 + Opt_lifetime, Opt_nolifetime, Opt_max_atomic_write, Opt_errortag, 119 118 }; 120 119 121 120 #define fsparam_dead(NAME) \ ··· 174 173 fsparam_flag("lifetime", Opt_lifetime), 175 174 fsparam_flag("nolifetime", Opt_nolifetime), 176 175 fsparam_string("max_atomic_write", Opt_max_atomic_write), 176 + fsparam_string("errortag", Opt_errortag), 177 177 {} 178 178 }; 179 179 ··· 1595 1593 return -EINVAL; 1596 1594 } 1597 1595 return 0; 1596 + case Opt_errortag: 1597 + return xfs_errortag_add_name(parsing_mp, param->string); 1598 1598 default: 1599 1599 xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); 1600 1600 return -EINVAL; ··· 2187 2183 error = xfs_fs_validate_params(new_mp); 2188 2184 if (error) 2189 2185 return error; 2186 + 2187 + xfs_errortag_copy(mp, new_mp); 2190 2188 2191 2189 /* Validate new max_atomic_write option before making other changes */ 2192 2190 if (mp->m_awu_max_bytes != new_mp->m_awu_max_bytes) {