aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/write.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-15 18:56:43 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:39:24 -0400
commit9c261b33a9c417ccaf07f41796be278d09d02d49 (patch)
tree6cf47f47364647dfbba845c0fd3f05539072175a /fs/jffs2/write.c
parentbf011f2ed53d587fdd8148c173c4f09ed77bdf1a (diff)
jffs2: Convert most D1/D2 macros to jffs2_dbg
D1 and D2 macros are mostly uses to emit debugging messages. Convert the logging uses of D1 & D2 to jffs2_dbg(level, fmt, ...) to be a bit more consistent style with the rest of the kernel. All jffs2_dbg output is now at KERN_DEBUG where some of the previous uses were emitted at various KERN_<LEVEL>s. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2/write.c')
-rw-r--r--fs/jffs2/write.c74
1 files changed, 41 insertions, 33 deletions
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index 30d175b6d290..e137839a157d 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -36,7 +36,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
36 f->inocache->state = INO_STATE_PRESENT; 36 f->inocache->state = INO_STATE_PRESENT;
37 37
38 jffs2_add_ino_cache(c, f->inocache); 38 jffs2_add_ino_cache(c, f->inocache);
39 D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); 39 jffs2_dbg(1, "%s(): Assigned ino# %d\n", __func__, f->inocache->ino);
40 ri->ino = cpu_to_je32(f->inocache->ino); 40 ri->ino = cpu_to_je32(f->inocache->ino);
41 41
42 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 42 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -95,9 +95,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
95 95
96 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { 96 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
97 BUG_ON(!retried); 97 BUG_ON(!retried);
98 D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " 98 jffs2_dbg(1, "%s(): dnode_version %d, highest version %d -> updating dnode\n",
99 "highest version %d -> updating dnode\n", 99 __func__,
100 je32_to_cpu(ri->version), f->highest_version)); 100 je32_to_cpu(ri->version), f->highest_version);
101 ri->version = cpu_to_je32(++f->highest_version); 101 ri->version = cpu_to_je32(++f->highest_version);
102 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); 102 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
103 } 103 }
@@ -127,7 +127,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
127 127
128 retried = 1; 128 retried = 1;
129 129
130 D1(printk(KERN_DEBUG "Retrying failed write.\n")); 130 jffs2_dbg(1, "Retrying failed write.\n");
131 131
132 jffs2_dbg_acct_sanity_check(c,jeb); 132 jffs2_dbg_acct_sanity_check(c,jeb);
133 jffs2_dbg_acct_paranoia_check(c, jeb); 133 jffs2_dbg_acct_paranoia_check(c, jeb);
@@ -147,14 +147,16 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
147 147
148 if (!ret) { 148 if (!ret) {
149 flash_ofs = write_ofs(c); 149 flash_ofs = write_ofs(c);
150 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); 150 jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n",
151 flash_ofs);
151 152
152 jffs2_dbg_acct_sanity_check(c,jeb); 153 jffs2_dbg_acct_sanity_check(c,jeb);
153 jffs2_dbg_acct_paranoia_check(c, jeb); 154 jffs2_dbg_acct_paranoia_check(c, jeb);
154 155
155 goto retry; 156 goto retry;
156 } 157 }
157 D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); 158 jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n",
159 ret);
158 } 160 }
159 /* Release the full_dnode which is now useless, and return */ 161 /* Release the full_dnode which is now useless, and return */
160 jffs2_free_full_dnode(fn); 162 jffs2_free_full_dnode(fn);
@@ -183,10 +185,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
183 fn->size = je32_to_cpu(ri->dsize); 185 fn->size = je32_to_cpu(ri->dsize);
184 fn->frags = 0; 186 fn->frags = 0;
185 187
186 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", 188 jffs2_dbg(1, "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
187 flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), 189 flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize),
188 je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), 190 je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc),
189 je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); 191 je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen));
190 192
191 if (retried) { 193 if (retried) {
192 jffs2_dbg_acct_sanity_check(c,NULL); 194 jffs2_dbg_acct_sanity_check(c,NULL);
@@ -206,9 +208,10 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
206 int retried = 0; 208 int retried = 0;
207 int ret; 209 int ret;
208 210
209 D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", 211 jffs2_dbg(1, "%s(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n",
212 __func__,
210 je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), 213 je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino),
211 je32_to_cpu(rd->name_crc))); 214 je32_to_cpu(rd->name_crc));
212 215
213 D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { 216 D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) {
214 printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); 217 printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n");
@@ -249,9 +252,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
249 252
250 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { 253 if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) {
251 BUG_ON(!retried); 254 BUG_ON(!retried);
252 D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " 255 jffs2_dbg(1, "%s(): dirent_version %d, highest version %d -> updating dirent\n",
253 "highest version %d -> updating dirent\n", 256 __func__,
254 je32_to_cpu(rd->version), f->highest_version)); 257 je32_to_cpu(rd->version), f->highest_version);
255 rd->version = cpu_to_je32(++f->highest_version); 258 rd->version = cpu_to_je32(++f->highest_version);
256 fd->version = je32_to_cpu(rd->version); 259 fd->version = je32_to_cpu(rd->version);
257 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); 260 rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
@@ -275,7 +278,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
275 278
276 retried = 1; 279 retried = 1;
277 280
278 D1(printk(KERN_DEBUG "Retrying failed write.\n")); 281 jffs2_dbg(1, "Retrying failed write.\n");
279 282
280 jffs2_dbg_acct_sanity_check(c,jeb); 283 jffs2_dbg_acct_sanity_check(c,jeb);
281 jffs2_dbg_acct_paranoia_check(c, jeb); 284 jffs2_dbg_acct_paranoia_check(c, jeb);
@@ -295,12 +298,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
295 298
296 if (!ret) { 299 if (!ret) {
297 flash_ofs = write_ofs(c); 300 flash_ofs = write_ofs(c);
298 D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); 301 jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write\n",
302 flash_ofs);
299 jffs2_dbg_acct_sanity_check(c,jeb); 303 jffs2_dbg_acct_sanity_check(c,jeb);
300 jffs2_dbg_acct_paranoia_check(c, jeb); 304 jffs2_dbg_acct_paranoia_check(c, jeb);
301 goto retry; 305 goto retry;
302 } 306 }
303 D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); 307 jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n",
308 ret);
304 } 309 }
305 /* Release the full_dnode which is now useless, and return */ 310 /* Release the full_dnode which is now useless, and return */
306 jffs2_free_full_dirent(fd); 311 jffs2_free_full_dirent(fd);
@@ -333,8 +338,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
333 int ret = 0; 338 int ret = 0;
334 uint32_t writtenlen = 0; 339 uint32_t writtenlen = 0;
335 340
336 D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", 341 jffs2_dbg(1, "%s(): Ino #%u, ofs 0x%x, len 0x%x\n",
337 f->inocache->ino, offset, writelen)); 342 __func__, f->inocache->ino, offset, writelen);
338 343
339 while(writelen) { 344 while(writelen) {
340 struct jffs2_full_dnode *fn; 345 struct jffs2_full_dnode *fn;
@@ -345,12 +350,13 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
345 int retried = 0; 350 int retried = 0;
346 351
347 retry: 352 retry:
348 D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); 353 jffs2_dbg(2, "jffs2_commit_write() loop: 0x%x to write to 0x%x\n",
354 writelen, offset);
349 355
350 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, 356 ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN,
351 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); 357 &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
352 if (ret) { 358 if (ret) {
353 D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); 359 jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret);
354 break; 360 break;
355 } 361 }
356 mutex_lock(&f->sem); 362 mutex_lock(&f->sem);
@@ -386,7 +392,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
386 if (!retried) { 392 if (!retried) {
387 /* Write error to be retried */ 393 /* Write error to be retried */
388 retried = 1; 394 retried = 1;
389 D1(printk(KERN_DEBUG "Retrying node write in jffs2_write_inode_range()\n")); 395 jffs2_dbg(1, "Retrying node write in jffs2_write_inode_range()\n");
390 goto retry; 396 goto retry;
391 } 397 }
392 break; 398 break;
@@ -399,7 +405,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
399 } 405 }
400 if (ret) { 406 if (ret) {
401 /* Eep */ 407 /* Eep */
402 D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", ret)); 408 jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n",
409 ret);
403 jffs2_mark_node_obsolete(c, fn->raw); 410 jffs2_mark_node_obsolete(c, fn->raw);
404 jffs2_free_full_dnode(fn); 411 jffs2_free_full_dnode(fn);
405 412
@@ -414,7 +421,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
414 ret = -EIO; 421 ret = -EIO;
415 break; 422 break;
416 } 423 }
417 D1(printk(KERN_DEBUG "increasing writtenlen by %d\n", datalen)); 424 jffs2_dbg(1, "increasing writtenlen by %d\n", datalen);
418 writtenlen += datalen; 425 writtenlen += datalen;
419 offset += datalen; 426 offset += datalen;
420 writelen -= datalen; 427 writelen -= datalen;
@@ -439,7 +446,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
439 */ 446 */
440 ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, 447 ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
441 JFFS2_SUMMARY_INODE_SIZE); 448 JFFS2_SUMMARY_INODE_SIZE);
442 D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); 449 jffs2_dbg(1, "%s(): reserved 0x%x bytes\n", __func__, alloclen);
443 if (ret) 450 if (ret)
444 return ret; 451 return ret;
445 452
@@ -450,11 +457,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
450 457
451 fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); 458 fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
452 459
453 D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n", 460 jffs2_dbg(1, "jffs2_do_create created file with mode 0x%x\n",
454 jemode_to_cpu(ri->mode))); 461 jemode_to_cpu(ri->mode));
455 462
456 if (IS_ERR(fn)) { 463 if (IS_ERR(fn)) {
457 D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); 464 jffs2_dbg(1, "jffs2_write_dnode() failed\n");
458 /* Eeek. Wave bye bye */ 465 /* Eeek. Wave bye bye */
459 mutex_unlock(&f->sem); 466 mutex_unlock(&f->sem);
460 jffs2_complete_reservation(c); 467 jffs2_complete_reservation(c);
@@ -480,7 +487,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
480 487
481 if (ret) { 488 if (ret) {
482 /* Eep. */ 489 /* Eep. */
483 D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); 490 jffs2_dbg(1, "jffs2_reserve_space() for dirent failed\n");
484 return ret; 491 return ret;
485 } 492 }
486 493
@@ -597,8 +604,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
597 !memcmp(fd->name, name, namelen) && 604 !memcmp(fd->name, name, namelen) &&
598 !fd->name[namelen]) { 605 !fd->name[namelen]) {
599 606
600 D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", 607 jffs2_dbg(1, "Marking old dirent node (ino #%u) @%08x obsolete\n",
601 fd->ino, ref_offset(fd->raw))); 608 fd->ino, ref_offset(fd->raw));
602 jffs2_mark_node_obsolete(c, fd->raw); 609 jffs2_mark_node_obsolete(c, fd->raw);
603 /* We don't want to remove it from the list immediately, 610 /* We don't want to remove it from the list immediately,
604 because that screws up getdents()/seek() semantics even 611 because that screws up getdents()/seek() semantics even
@@ -630,8 +637,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
630 printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", 637 printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n",
631 dead_f->inocache->ino, fd->name, fd->ino); 638 dead_f->inocache->ino, fd->name, fd->ino);
632 } else { 639 } else {
633 D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", 640 jffs2_dbg(1, "Removing deletion dirent for \"%s\" from dir ino #%u\n",
634 fd->name, dead_f->inocache->ino)); 641 fd->name,
642 dead_f->inocache->ino);
635 } 643 }
636 if (fd->raw) 644 if (fd->raw)
637 jffs2_mark_node_obsolete(c, fd->raw); 645 jffs2_mark_node_obsolete(c, fd->raw);