aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2016-08-02 17:05:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:16 -0400
commitcae3d4ca6fd6872d8e9c21eff0e56398c938100a (patch)
treef333245bd16018ea3201aa6fde62454a9f84ff53
parenta310dcb7a43f971ee7d810fbbe36bd766a299717 (diff)
nilfs2: hide function name argument from nilfs_error()
Simplify nilfs_error(), an output function used to report critical issues in file system. This renames the original nilfs_error() function to __nilfs_error() and redefines it as a macro to hide its function name argument within the macro. Every call site of nilfs_error() is changed to strip __func__ argument except nilfs_bmap_convert_error(); nilfs_bmap_convert_error() directly calls __nilfs_error() because it inherits caller's function name. Link: http://lkml.kernel.org/r/1464875891-5443-2-git-send-email-konishi.ryusuke@lab.ntt.co.jp Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nilfs2/bmap.c4
-rw-r--r--fs/nilfs2/dir.c38
-rw-r--r--fs/nilfs2/ifile.c3
-rw-r--r--fs/nilfs2/nilfs.h20
-rw-r--r--fs/nilfs2/super.c22
5 files changed, 51 insertions, 36 deletions
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index f2a7877e0c8c..01fb1831ca25 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -41,8 +41,8 @@ static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap,
41 struct inode *inode = bmap->b_inode; 41 struct inode *inode = bmap->b_inode;
42 42
43 if (err == -EINVAL) { 43 if (err == -EINVAL) {
44 nilfs_error(inode->i_sb, fname, 44 __nilfs_error(inode->i_sb, fname,
45 "broken bmap (inode number=%lu)", inode->i_ino); 45 "broken bmap (inode number=%lu)", inode->i_ino);
46 err = -EIO; 46 err = -EIO;
47 } 47 }
48 return err; 48 return err;
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index e506f4f7120a..746956d2937a 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -140,10 +140,9 @@ out:
140 /* Too bad, we had an error */ 140 /* Too bad, we had an error */
141 141
142Ebadsize: 142Ebadsize:
143 nilfs_error(sb, "nilfs_check_page", 143 nilfs_error(sb,
144 "size of directory #%lu is not a multiple of chunk size", 144 "size of directory #%lu is not a multiple of chunk size",
145 dir->i_ino 145 dir->i_ino);
146 );
147 goto fail; 146 goto fail;
148Eshort: 147Eshort:
149 error = "rec_len is smaller than minimal"; 148 error = "rec_len is smaller than minimal";
@@ -157,19 +156,18 @@ Enamelen:
157Espan: 156Espan:
158 error = "directory entry across blocks"; 157 error = "directory entry across blocks";
159bad_entry: 158bad_entry:
160 nilfs_error(sb, "nilfs_check_page", "bad entry in directory #%lu: %s - " 159 nilfs_error(sb,
161 "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", 160 "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
162 dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs, 161 dir->i_ino, error, (page->index << PAGE_SHIFT) + offs,
163 (unsigned long) le64_to_cpu(p->inode), 162 (unsigned long)le64_to_cpu(p->inode),
164 rec_len, p->name_len); 163 rec_len, p->name_len);
165 goto fail; 164 goto fail;
166Eend: 165Eend:
167 p = (struct nilfs_dir_entry *)(kaddr + offs); 166 p = (struct nilfs_dir_entry *)(kaddr + offs);
168 nilfs_error(sb, "nilfs_check_page", 167 nilfs_error(sb,
169 "entry in directory #%lu spans the page boundary" 168 "entry in directory #%lu spans the page boundary offset=%lu, inode=%lu",
170 "offset=%lu, inode=%lu", 169 dir->i_ino, (page->index << PAGE_SHIFT) + offs,
171 dir->i_ino, (page->index<<PAGE_SHIFT)+offs, 170 (unsigned long)le64_to_cpu(p->inode));
172 (unsigned long) le64_to_cpu(p->inode));
173fail: 171fail:
174 SetPageError(page); 172 SetPageError(page);
175 return false; 173 return false;
@@ -267,8 +265,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx)
267 struct page *page = nilfs_get_page(inode, n); 265 struct page *page = nilfs_get_page(inode, n);
268 266
269 if (IS_ERR(page)) { 267 if (IS_ERR(page)) {
270 nilfs_error(sb, __func__, "bad page in #%lu", 268 nilfs_error(sb, "bad page in #%lu", inode->i_ino);
271 inode->i_ino);
272 ctx->pos += PAGE_SIZE - offset; 269 ctx->pos += PAGE_SIZE - offset;
273 return -EIO; 270 return -EIO;
274 } 271 }
@@ -278,8 +275,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx)
278 NILFS_DIR_REC_LEN(1); 275 NILFS_DIR_REC_LEN(1);
279 for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) { 276 for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) {
280 if (de->rec_len == 0) { 277 if (de->rec_len == 0) {
281 nilfs_error(sb, __func__, 278 nilfs_error(sb, "zero-length directory entry");
282 "zero-length directory entry");
283 nilfs_put_page(page); 279 nilfs_put_page(page);
284 return -EIO; 280 return -EIO;
285 } 281 }
@@ -345,7 +341,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
345 kaddr += nilfs_last_byte(dir, n) - reclen; 341 kaddr += nilfs_last_byte(dir, n) - reclen;
346 while ((char *) de <= kaddr) { 342 while ((char *) de <= kaddr) {
347 if (de->rec_len == 0) { 343 if (de->rec_len == 0) {
348 nilfs_error(dir->i_sb, __func__, 344 nilfs_error(dir->i_sb,
349 "zero-length directory entry"); 345 "zero-length directory entry");
350 nilfs_put_page(page); 346 nilfs_put_page(page);
351 goto out; 347 goto out;
@@ -360,7 +356,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
360 n = 0; 356 n = 0;
361 /* next page is past the blocks we've got */ 357 /* next page is past the blocks we've got */
362 if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) { 358 if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) {
363 nilfs_error(dir->i_sb, __func__, 359 nilfs_error(dir->i_sb,
364 "dir %lu size %lld exceeds block count %llu", 360 "dir %lu size %lld exceeds block count %llu",
365 dir->i_ino, dir->i_size, 361 dir->i_ino, dir->i_size,
366 (unsigned long long)dir->i_blocks); 362 (unsigned long long)dir->i_blocks);
@@ -469,7 +465,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
469 goto got_it; 465 goto got_it;
470 } 466 }
471 if (de->rec_len == 0) { 467 if (de->rec_len == 0) {
472 nilfs_error(dir->i_sb, __func__, 468 nilfs_error(dir->i_sb,
473 "zero-length directory entry"); 469 "zero-length directory entry");
474 err = -EIO; 470 err = -EIO;
475 goto out_unlock; 471 goto out_unlock;
@@ -541,7 +537,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
541 537
542 while ((char *)de < (char *)dir) { 538 while ((char *)de < (char *)dir) {
543 if (de->rec_len == 0) { 539 if (de->rec_len == 0) {
544 nilfs_error(inode->i_sb, __func__, 540 nilfs_error(inode->i_sb,
545 "zero-length directory entry"); 541 "zero-length directory entry");
546 err = -EIO; 542 err = -EIO;
547 goto out; 543 goto out;
@@ -628,7 +624,7 @@ int nilfs_empty_dir(struct inode *inode)
628 624
629 while ((char *)de <= kaddr) { 625 while ((char *)de <= kaddr) {
630 if (de->rec_len == 0) { 626 if (de->rec_len == 0) {
631 nilfs_error(inode->i_sb, __func__, 627 nilfs_error(inode->i_sb,
632 "zero-length directory entry (kaddr=%p, de=%p)", 628 "zero-length directory entry (kaddr=%p, de=%p)",
633 kaddr, de); 629 kaddr, de);
634 goto not_empty; 630 goto not_empty;
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c
index 1d2b1805327a..b1c96285aa4a 100644
--- a/fs/nilfs2/ifile.c
+++ b/fs/nilfs2/ifile.c
@@ -145,8 +145,7 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
145 int err; 145 int err;
146 146
147 if (unlikely(!NILFS_VALID_INODE(sb, ino))) { 147 if (unlikely(!NILFS_VALID_INODE(sb, ino))) {
148 nilfs_error(sb, __func__, "bad inode number: %lu", 148 nilfs_error(sb, "bad inode number: %lu", (unsigned long)ino);
149 (unsigned long) ino);
150 return -EINVAL; 149 return -EINVAL;
151 } 150 }
152 151
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index b1d48bc0532d..e482c78bcc86 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -299,10 +299,28 @@ static inline int nilfs_mark_inode_dirty_sync(struct inode *inode)
299/* super.c */ 299/* super.c */
300extern struct inode *nilfs_alloc_inode(struct super_block *); 300extern struct inode *nilfs_alloc_inode(struct super_block *);
301extern void nilfs_destroy_inode(struct inode *); 301extern void nilfs_destroy_inode(struct inode *);
302
302extern __printf(3, 4) 303extern __printf(3, 4)
303void nilfs_error(struct super_block *, const char *, const char *, ...); 304void __nilfs_error(struct super_block *sb, const char *function,
305 const char *fmt, ...);
304extern __printf(3, 4) 306extern __printf(3, 4)
305void nilfs_warning(struct super_block *, const char *, const char *, ...); 307void nilfs_warning(struct super_block *, const char *, const char *, ...);
308
309#ifdef CONFIG_PRINTK
310
311#define nilfs_error(sb, fmt, ...) \
312 __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__)
313
314#else
315
316#define nilfs_error(sb, fmt, ...) \
317 do { \
318 no_printk(fmt, ##__VA_ARGS__); \
319 __nilfs_error(sb, "", " "); \
320 } while (0)
321
322#endif /* CONFIG_PRINTK */
323
306extern struct nilfs_super_block * 324extern struct nilfs_super_block *
307nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); 325nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
308extern int nilfs_store_magic_and_option(struct super_block *, 326extern int nilfs_store_magic_and_option(struct super_block *,
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 666107a18a22..7fe497eb2181 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -91,19 +91,21 @@ static void nilfs_set_error(struct super_block *sb)
91} 91}
92 92
93/** 93/**
94 * nilfs_error() - report failure condition on a filesystem 94 * __nilfs_error() - report failure condition on a filesystem
95 * 95 *
96 * nilfs_error() sets an ERROR_FS flag on the superblock as well as 96 * __nilfs_error() sets an ERROR_FS flag on the superblock as well as
97 * reporting an error message. It should be called when NILFS detects 97 * reporting an error message. This function should be called when
98 * incoherences or defects of meta data on disk. As for sustainable 98 * NILFS detects incoherences or defects of meta data on disk.
99 * errors such as a single-shot I/O error, nilfs_warning() or the printk()
100 * function should be used instead.
101 * 99 *
102 * The segment constructor must not call this function because it can 100 * This implements the body of nilfs_error() macro. Normally,
103 * kill itself. 101 * nilfs_error() should be used. As for sustainable errors such as a
102 * single-shot I/O error, nilfs_warning() or printk() should be used
103 * instead.
104 *
105 * Callers should not add a trailing newline since this will do it.
104 */ 106 */
105void nilfs_error(struct super_block *sb, const char *function, 107void __nilfs_error(struct super_block *sb, const char *function,
106 const char *fmt, ...) 108 const char *fmt, ...)
107{ 109{
108 struct the_nilfs *nilfs = sb->s_fs_info; 110 struct the_nilfs *nilfs = sb->s_fs_info;
109 struct va_format vaf; 111 struct va_format vaf;