aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2015-08-14 06:32:52 -0400
committerDavid Sterba <dsterba@suse.com>2015-09-29 10:30:00 -0400
commit57d816a15ba2c2690c57635134bc01cf4da4623c (patch)
tree9457a7ff7bb5bf280abdbbc8d85c971d96ba7c84
parent92fc03fbdcbe2523be3f7e6b8e95fee9563a10d2 (diff)
Btrfs: __btrfs_std_error() logic should be consistent w/out CONFIG_PRINTK defined
error handling logic behaves differently with or without CONFIG_PRINTK defined, since there are two copies of the same function which a bit of different logic One, when CONFIG_PRINTK is defined, code is __btrfs_std_error(..) { :: save_error_info(fs_info); if (sb->s_flags & MS_BORN) btrfs_handle_error(fs_info); } and two when CONFIG_PRINTK is not defined, the code is __btrfs_std_error(..) { :: if (sb->s_flags & MS_BORN) { save_error_info(fs_info); btrfs_handle_error(fs_info); } } I doubt if this was intentional ? and appear to have caused since we maintain two copies of the same function and they got diverged with commits. Now to decide which logic is correct reviewed changes as below, 533574c6bc30cf526cc1c41bde050c854a945efb Commit added two copies of this function cf79ffb5b79e8a2b587fbf218809e691bb396c98 Commit made change to only one copy of the function and to the copy when CONFIG_PRINTK is defined. To fix this, instead of maintaining two copies of same function approach, maintain single function, and just put the extra portion of the code under CONFIG_PRINTK define. This patch just does that. And keeps code of with CONFIG_PRINTK defined. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/super.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 11d1eab9234d..b23d49daa1a2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -130,7 +130,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
130 } 130 }
131} 131}
132 132
133#ifdef CONFIG_PRINTK
134/* 133/*
135 * __btrfs_std_error decodes expected errors from the caller and 134 * __btrfs_std_error decodes expected errors from the caller and
136 * invokes the approciate error response. 135 * invokes the approciate error response.
@@ -140,7 +139,9 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
140 unsigned int line, int errno, const char *fmt, ...) 139 unsigned int line, int errno, const char *fmt, ...)
141{ 140{
142 struct super_block *sb = fs_info->sb; 141 struct super_block *sb = fs_info->sb;
142#ifdef CONFIG_PRINTK
143 const char *errstr; 143 const char *errstr;
144#endif
144 145
145 /* 146 /*
146 * Special case: if the error is EROFS, and we're already 147 * Special case: if the error is EROFS, and we're already
@@ -149,6 +150,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
149 if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) 150 if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
150 return; 151 return;
151 152
153#ifdef CONFIG_PRINTK
152 errstr = btrfs_decode_error(errno); 154 errstr = btrfs_decode_error(errno);
153 if (fmt) { 155 if (fmt) {
154 struct va_format vaf; 156 struct va_format vaf;
@@ -166,6 +168,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
166 printk(KERN_CRIT "BTRFS: error (device %s) in %s:%d: errno=%d %s\n", 168 printk(KERN_CRIT "BTRFS: error (device %s) in %s:%d: errno=%d %s\n",
167 sb->s_id, function, line, errno, errstr); 169 sb->s_id, function, line, errno, errstr);
168 } 170 }
171#endif
169 172
170 /* Don't go through full error handling during mount */ 173 /* Don't go through full error handling during mount */
171 save_error_info(fs_info); 174 save_error_info(fs_info);
@@ -173,6 +176,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
173 btrfs_handle_error(fs_info); 176 btrfs_handle_error(fs_info);
174} 177}
175 178
179#ifdef CONFIG_PRINTK
176static const char * const logtypes[] = { 180static const char * const logtypes[] = {
177 "emergency", 181 "emergency",
178 "alert", 182 "alert",
@@ -212,27 +216,6 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
212 216
213 va_end(args); 217 va_end(args);
214} 218}
215
216#else
217
218void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
219 unsigned int line, int errno, const char *fmt, ...)
220{
221 struct super_block *sb = fs_info->sb;
222
223 /*
224 * Special case: if the error is EROFS, and we're already
225 * under MS_RDONLY, then it is safe here.
226 */
227 if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
228 return;
229
230 /* Don't go through full error handling during mount */
231 if (sb->s_flags & MS_BORN) {
232 save_error_info(fs_info);
233 btrfs_handle_error(fs_info);
234 }
235}
236#endif 219#endif
237 220
238/* 221/*