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: allocate m_errortag early

Ensure the mount structure always has a valid m_errortag for debug
builds. This removes the NULL checking from the runtime code, and
prepares for allowing to set errortags from mount.

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

authored by

Christoph Hellwig and committed by
Carlos Maiolino
394969e2 9a228d14

+13 -25
+1 -25
fs/xfs/xfs_error.c
··· 114 114 xfs_errortag_init( 115 115 struct xfs_mount *mp) 116 116 { 117 - int ret; 118 - 119 - mp->m_errortag = kzalloc(sizeof(unsigned int) * XFS_ERRTAG_MAX, 120 - GFP_KERNEL | __GFP_RETRY_MAYFAIL); 121 - if (!mp->m_errortag) 122 - return -ENOMEM; 123 - 124 - ret = xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype, 117 + return xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype, 125 118 &mp->m_kobj, "errortag"); 126 - if (ret) 127 - kfree(mp->m_errortag); 128 - return ret; 129 119 } 130 120 131 121 void ··· 123 133 struct xfs_mount *mp) 124 134 { 125 135 xfs_sysfs_del(&mp->m_errortag_kobj); 126 - kfree(mp->m_errortag); 127 136 } 128 137 129 138 static bool ··· 143 154 struct xfs_mount *mp, 144 155 unsigned int tag) 145 156 { 146 - if (!mp->m_errortag) 147 - return false; 148 157 if (!xfs_errortag_valid(tag)) 149 158 return false; 150 159 ··· 157 170 unsigned int error_tag) 158 171 { 159 172 unsigned int randfactor; 160 - 161 - /* 162 - * To be able to use error injection anywhere, we need to ensure error 163 - * injection mechanism is already initialized. 164 - * 165 - * Code paths like I/O completion can be called before the 166 - * initialization is complete, but be able to inject errors in such 167 - * places is still useful. 168 - */ 169 - if (!mp->m_errortag) 170 - return false; 171 173 172 174 if (!xfs_errortag_valid(error_tag)) 173 175 return false;
+12
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_errortag.h" 43 44 #include "xfs_iunlink_item.h" 44 45 #include "xfs_dahash_test.h" 45 46 #include "xfs_rtbitmap.h" ··· 825 824 debugfs_remove(mp->m_debugfs); 826 825 kfree(mp->m_rtname); 827 826 kfree(mp->m_logname); 827 + #ifdef DEBUG 828 + kfree(mp->m_errortag); 829 + #endif 828 830 kfree(mp); 829 831 } 830 832 ··· 2270 2266 mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL); 2271 2267 if (!mp) 2272 2268 return -ENOMEM; 2269 + #ifdef DEBUG 2270 + mp->m_errortag = kcalloc(XFS_ERRTAG_MAX, sizeof(*mp->m_errortag), 2271 + GFP_KERNEL); 2272 + if (!mp->m_errortag) { 2273 + kfree(mp); 2274 + return -ENOMEM; 2275 + } 2276 + #endif 2273 2277 2274 2278 spin_lock_init(&mp->m_sb_lock); 2275 2279 for (i = 0; i < XG_TYPE_MAX; i++)