.. | .. |
---|
158 | 158 | * it is saved and will be restored on |
---|
159 | 159 | * nilfs_transaction_commit(). |
---|
160 | 160 | */ |
---|
161 | | - nilfs_msg(sb, KERN_WARNING, "journal info from a different FS"); |
---|
| 161 | + nilfs_warn(sb, "journal info from a different FS"); |
---|
162 | 162 | save = current->journal_info; |
---|
163 | 163 | } |
---|
164 | 164 | if (!ti) { |
---|
.. | .. |
---|
322 | 322 | struct the_nilfs *nilfs = sb->s_fs_info; |
---|
323 | 323 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
---|
324 | 324 | |
---|
325 | | - if (!sci || !sci->sc_flush_request) |
---|
| 325 | + if (sb_rdonly(sb) || unlikely(!sci) || !sci->sc_flush_request) |
---|
326 | 326 | return; |
---|
327 | 327 | |
---|
328 | 328 | set_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags); |
---|
.. | .. |
---|
738 | 738 | struct list_head *listp) |
---|
739 | 739 | { |
---|
740 | 740 | struct nilfs_inode_info *ii = NILFS_I(inode); |
---|
741 | | - struct address_space *mapping = &ii->i_btnode_cache; |
---|
| 741 | + struct inode *btnc_inode = ii->i_assoc_inode; |
---|
742 | 742 | struct pagevec pvec; |
---|
743 | 743 | struct buffer_head *bh, *head; |
---|
744 | 744 | unsigned int i; |
---|
745 | 745 | pgoff_t index = 0; |
---|
746 | 746 | |
---|
| 747 | + if (!btnc_inode) |
---|
| 748 | + return; |
---|
| 749 | + |
---|
747 | 750 | pagevec_init(&pvec); |
---|
748 | 751 | |
---|
749 | | - while (pagevec_lookup_tag(&pvec, mapping, &index, |
---|
| 752 | + while (pagevec_lookup_tag(&pvec, btnc_inode->i_mapping, &index, |
---|
750 | 753 | PAGECACHE_TAG_DIRTY)) { |
---|
751 | 754 | for (i = 0; i < pagevec_count(&pvec); i++) { |
---|
752 | 755 | bh = head = page_buffers(pvec.pages[i]); |
---|
.. | .. |
---|
877 | 880 | nilfs_mdt_mark_dirty(nilfs->ns_cpfile); |
---|
878 | 881 | nilfs_cpfile_put_checkpoint( |
---|
879 | 882 | nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); |
---|
880 | | - } else |
---|
881 | | - WARN_ON(err == -EINVAL || err == -ENOENT); |
---|
882 | | - |
---|
| 883 | + } else if (err == -EINVAL || err == -ENOENT) { |
---|
| 884 | + nilfs_error(sci->sc_super, |
---|
| 885 | + "checkpoint creation failed due to metadata corruption."); |
---|
| 886 | + err = -EIO; |
---|
| 887 | + } |
---|
883 | 888 | return err; |
---|
884 | 889 | } |
---|
885 | 890 | |
---|
.. | .. |
---|
893 | 898 | err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0, |
---|
894 | 899 | &raw_cp, &bh_cp); |
---|
895 | 900 | if (unlikely(err)) { |
---|
896 | | - WARN_ON(err == -EINVAL || err == -ENOENT); |
---|
| 901 | + if (err == -EINVAL || err == -ENOENT) { |
---|
| 902 | + nilfs_error(sci->sc_super, |
---|
| 903 | + "checkpoint finalization failed due to metadata corruption."); |
---|
| 904 | + err = -EIO; |
---|
| 905 | + } |
---|
897 | 906 | goto failed_ibh; |
---|
898 | 907 | } |
---|
899 | 908 | raw_cp->cp_snapshot_list.ssl_next = 0; |
---|
.. | .. |
---|
1138 | 1147 | nilfs_sc_cstage_set(sci, NILFS_ST_DAT); |
---|
1139 | 1148 | goto dat_stage; |
---|
1140 | 1149 | } |
---|
1141 | | - nilfs_sc_cstage_inc(sci); /* Fall through */ |
---|
| 1150 | + nilfs_sc_cstage_inc(sci); |
---|
| 1151 | + fallthrough; |
---|
1142 | 1152 | case NILFS_ST_GC: |
---|
1143 | 1153 | if (nilfs_doing_gc()) { |
---|
1144 | 1154 | head = &sci->sc_gc_inodes; |
---|
.. | .. |
---|
1159 | 1169 | } |
---|
1160 | 1170 | sci->sc_stage.gc_inode_ptr = NULL; |
---|
1161 | 1171 | } |
---|
1162 | | - nilfs_sc_cstage_inc(sci); /* Fall through */ |
---|
| 1172 | + nilfs_sc_cstage_inc(sci); |
---|
| 1173 | + fallthrough; |
---|
1163 | 1174 | case NILFS_ST_FILE: |
---|
1164 | 1175 | head = &sci->sc_dirty_files; |
---|
1165 | 1176 | ii = list_prepare_entry(sci->sc_stage.dirty_file_ptr, head, |
---|
.. | .. |
---|
1186 | 1197 | } |
---|
1187 | 1198 | nilfs_sc_cstage_inc(sci); |
---|
1188 | 1199 | sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED; |
---|
1189 | | - /* Fall through */ |
---|
| 1200 | + fallthrough; |
---|
1190 | 1201 | case NILFS_ST_IFILE: |
---|
1191 | 1202 | err = nilfs_segctor_scan_file(sci, sci->sc_root->ifile, |
---|
1192 | 1203 | &nilfs_sc_file_ops); |
---|
.. | .. |
---|
1197 | 1208 | err = nilfs_segctor_create_checkpoint(sci); |
---|
1198 | 1209 | if (unlikely(err)) |
---|
1199 | 1210 | break; |
---|
1200 | | - /* Fall through */ |
---|
| 1211 | + fallthrough; |
---|
1201 | 1212 | case NILFS_ST_CPFILE: |
---|
1202 | 1213 | err = nilfs_segctor_scan_file(sci, nilfs->ns_cpfile, |
---|
1203 | 1214 | &nilfs_sc_file_ops); |
---|
1204 | 1215 | if (unlikely(err)) |
---|
1205 | 1216 | break; |
---|
1206 | | - nilfs_sc_cstage_inc(sci); /* Fall through */ |
---|
| 1217 | + nilfs_sc_cstage_inc(sci); |
---|
| 1218 | + fallthrough; |
---|
1207 | 1219 | case NILFS_ST_SUFILE: |
---|
1208 | 1220 | err = nilfs_sufile_freev(nilfs->ns_sufile, sci->sc_freesegs, |
---|
1209 | 1221 | sci->sc_nfreesegs, &ndone); |
---|
.. | .. |
---|
1219 | 1231 | &nilfs_sc_file_ops); |
---|
1220 | 1232 | if (unlikely(err)) |
---|
1221 | 1233 | break; |
---|
1222 | | - nilfs_sc_cstage_inc(sci); /* Fall through */ |
---|
| 1234 | + nilfs_sc_cstage_inc(sci); |
---|
| 1235 | + fallthrough; |
---|
1223 | 1236 | case NILFS_ST_DAT: |
---|
1224 | 1237 | dat_stage: |
---|
1225 | 1238 | err = nilfs_segctor_scan_file(sci, nilfs->ns_dat, |
---|
.. | .. |
---|
1230 | 1243 | nilfs_sc_cstage_set(sci, NILFS_ST_DONE); |
---|
1231 | 1244 | return 0; |
---|
1232 | 1245 | } |
---|
1233 | | - nilfs_sc_cstage_inc(sci); /* Fall through */ |
---|
| 1246 | + nilfs_sc_cstage_inc(sci); |
---|
| 1247 | + fallthrough; |
---|
1234 | 1248 | case NILFS_ST_SR: |
---|
1235 | 1249 | if (mode == SC_LSEG_SR) { |
---|
1236 | 1250 | /* Appending a super root */ |
---|
.. | .. |
---|
1940 | 1954 | err = nilfs_ifile_get_inode_block( |
---|
1941 | 1955 | ifile, ii->vfs_inode.i_ino, &ibh); |
---|
1942 | 1956 | if (unlikely(err)) { |
---|
1943 | | - nilfs_msg(sci->sc_super, KERN_WARNING, |
---|
1944 | | - "log writer: error %d getting inode block (ino=%lu)", |
---|
1945 | | - err, ii->vfs_inode.i_ino); |
---|
| 1957 | + nilfs_warn(sci->sc_super, |
---|
| 1958 | + "log writer: error %d getting inode block (ino=%lu)", |
---|
| 1959 | + err, ii->vfs_inode.i_ino); |
---|
1946 | 1960 | return err; |
---|
1947 | 1961 | } |
---|
1948 | 1962 | spin_lock(&nilfs->ns_inode_lock); |
---|
.. | .. |
---|
2234 | 2248 | struct nilfs_transaction_info *ti; |
---|
2235 | 2249 | int err; |
---|
2236 | 2250 | |
---|
2237 | | - if (!sci) |
---|
| 2251 | + if (sb_rdonly(sb) || unlikely(!sci)) |
---|
2238 | 2252 | return -EROFS; |
---|
2239 | 2253 | |
---|
2240 | 2254 | /* A call inside transactions causes a deadlock. */ |
---|
.. | .. |
---|
2273 | 2287 | struct nilfs_transaction_info ti; |
---|
2274 | 2288 | int err = 0; |
---|
2275 | 2289 | |
---|
2276 | | - if (!sci) |
---|
| 2290 | + if (sb_rdonly(sb) || unlikely(!sci)) |
---|
2277 | 2291 | return -EROFS; |
---|
2278 | 2292 | |
---|
2279 | 2293 | nilfs_transaction_lock(sb, &ti, 0); |
---|
.. | .. |
---|
2410 | 2424 | continue; |
---|
2411 | 2425 | list_del_init(&ii->i_dirty); |
---|
2412 | 2426 | truncate_inode_pages(&ii->vfs_inode.i_data, 0); |
---|
2413 | | - nilfs_btnode_cache_clear(&ii->i_btnode_cache); |
---|
| 2427 | + nilfs_btnode_cache_clear(ii->i_assoc_inode->i_mapping); |
---|
2414 | 2428 | iput(&ii->vfs_inode); |
---|
2415 | 2429 | } |
---|
2416 | 2430 | } |
---|
.. | .. |
---|
2449 | 2463 | if (likely(!err)) |
---|
2450 | 2464 | break; |
---|
2451 | 2465 | |
---|
2452 | | - nilfs_msg(sb, KERN_WARNING, "error %d cleaning segments", err); |
---|
| 2466 | + nilfs_warn(sb, "error %d cleaning segments", err); |
---|
2453 | 2467 | set_current_state(TASK_INTERRUPTIBLE); |
---|
2454 | 2468 | schedule_timeout(sci->sc_interval); |
---|
2455 | 2469 | } |
---|
.. | .. |
---|
2457 | 2471 | int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, |
---|
2458 | 2472 | sci->sc_nfreesegs); |
---|
2459 | 2473 | if (ret) { |
---|
2460 | | - nilfs_msg(sb, KERN_WARNING, |
---|
2461 | | - "error %d on discard request, turning discards off for the device", |
---|
2462 | | - ret); |
---|
| 2474 | + nilfs_warn(sb, |
---|
| 2475 | + "error %d on discard request, turning discards off for the device", |
---|
| 2476 | + ret); |
---|
2463 | 2477 | nilfs_clear_opt(nilfs, DISCARD); |
---|
2464 | 2478 | } |
---|
2465 | 2479 | } |
---|
.. | .. |
---|
2540 | 2554 | /* start sync. */ |
---|
2541 | 2555 | sci->sc_task = current; |
---|
2542 | 2556 | wake_up(&sci->sc_wait_task); /* for nilfs_segctor_start_thread() */ |
---|
2543 | | - nilfs_msg(sci->sc_super, KERN_INFO, |
---|
2544 | | - "segctord starting. Construction interval = %lu seconds, CP frequency < %lu seconds", |
---|
2545 | | - sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ); |
---|
| 2557 | + nilfs_info(sci->sc_super, |
---|
| 2558 | + "segctord starting. Construction interval = %lu seconds, CP frequency < %lu seconds", |
---|
| 2559 | + sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ); |
---|
2546 | 2560 | |
---|
2547 | 2561 | spin_lock(&sci->sc_state_lock); |
---|
2548 | 2562 | loop: |
---|
.. | .. |
---|
2616 | 2630 | if (IS_ERR(t)) { |
---|
2617 | 2631 | int err = PTR_ERR(t); |
---|
2618 | 2632 | |
---|
2619 | | - nilfs_msg(sci->sc_super, KERN_ERR, |
---|
2620 | | - "error %d creating segctord thread", err); |
---|
| 2633 | + nilfs_err(sci->sc_super, "error %d creating segctord thread", |
---|
| 2634 | + err); |
---|
2621 | 2635 | return err; |
---|
2622 | 2636 | } |
---|
2623 | 2637 | wait_event(sci->sc_wait_task, sci->sc_task != NULL); |
---|
.. | .. |
---|
2727 | 2741 | nilfs_segctor_write_out(sci); |
---|
2728 | 2742 | |
---|
2729 | 2743 | if (!list_empty(&sci->sc_dirty_files)) { |
---|
2730 | | - nilfs_msg(sci->sc_super, KERN_WARNING, |
---|
2731 | | - "disposed unprocessed dirty file(s) when stopping log writer"); |
---|
| 2744 | + nilfs_warn(sci->sc_super, |
---|
| 2745 | + "disposed unprocessed dirty file(s) when stopping log writer"); |
---|
2732 | 2746 | nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1); |
---|
2733 | 2747 | } |
---|
2734 | 2748 | |
---|
2735 | 2749 | if (!list_empty(&sci->sc_iput_queue)) { |
---|
2736 | | - nilfs_msg(sci->sc_super, KERN_WARNING, |
---|
2737 | | - "disposed unprocessed inode(s) in iput queue when stopping log writer"); |
---|
| 2750 | + nilfs_warn(sci->sc_super, |
---|
| 2751 | + "disposed unprocessed inode(s) in iput queue when stopping log writer"); |
---|
2738 | 2752 | nilfs_dispose_list(nilfs, &sci->sc_iput_queue, 1); |
---|
2739 | 2753 | } |
---|
2740 | 2754 | |
---|
.. | .. |
---|
2769 | 2783 | |
---|
2770 | 2784 | if (nilfs->ns_writer) { |
---|
2771 | 2785 | /* |
---|
2772 | | - * This happens if the filesystem was remounted |
---|
2773 | | - * read/write after nilfs_error degenerated it into a |
---|
2774 | | - * read-only mount. |
---|
| 2786 | + * This happens if the filesystem is made read-only by |
---|
| 2787 | + * __nilfs_error or nilfs_remount and then remounted |
---|
| 2788 | + * read/write. In these cases, reuse the existing |
---|
| 2789 | + * writer. |
---|
2775 | 2790 | */ |
---|
2776 | | - nilfs_detach_log_writer(sb); |
---|
| 2791 | + return 0; |
---|
2777 | 2792 | } |
---|
2778 | 2793 | |
---|
2779 | 2794 | nilfs->ns_writer = nilfs_segctor_new(sb, root); |
---|
.. | .. |
---|
2783 | 2798 | inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL); |
---|
2784 | 2799 | |
---|
2785 | 2800 | err = nilfs_segctor_start_thread(nilfs->ns_writer); |
---|
2786 | | - if (err) { |
---|
2787 | | - kfree(nilfs->ns_writer); |
---|
2788 | | - nilfs->ns_writer = NULL; |
---|
2789 | | - } |
---|
| 2801 | + if (unlikely(err)) |
---|
| 2802 | + nilfs_detach_log_writer(sb); |
---|
| 2803 | + |
---|
2790 | 2804 | return err; |
---|
2791 | 2805 | } |
---|
2792 | 2806 | |
---|
.. | .. |
---|
2812 | 2826 | spin_lock(&nilfs->ns_inode_lock); |
---|
2813 | 2827 | if (!list_empty(&nilfs->ns_dirty_files)) { |
---|
2814 | 2828 | list_splice_init(&nilfs->ns_dirty_files, &garbage_list); |
---|
2815 | | - nilfs_msg(sb, KERN_WARNING, |
---|
2816 | | - "disposed unprocessed dirty file(s) when detaching log writer"); |
---|
| 2829 | + nilfs_warn(sb, |
---|
| 2830 | + "disposed unprocessed dirty file(s) when detaching log writer"); |
---|
2817 | 2831 | } |
---|
2818 | 2832 | spin_unlock(&nilfs->ns_inode_lock); |
---|
2819 | 2833 | up_write(&nilfs->ns_segctor_sem); |
---|