]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nilfs2/segment.c
nilfs2: clean up sketch file
[linux-2.6-omap-h63xx.git] / fs / nilfs2 / segment.c
index ad65a737aff4dcc7a29399f25f57a7f7028e37ff..981c34a0cd69d26724933bc378422825618e1700 100644 (file)
@@ -67,7 +67,6 @@ enum {
        NILFS_ST_INIT = 0,
        NILFS_ST_GC,            /* Collecting dirty blocks for GC */
        NILFS_ST_FILE,
-       NILFS_ST_SKETCH,
        NILFS_ST_IFILE,
        NILFS_ST_CPFILE,
        NILFS_ST_SUFILE,
@@ -163,8 +162,8 @@ static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
                else {
                        /*
                         * If journal_info field is occupied by other FS,
-                        * we save it and restore on nilfs_transaction_end().
-                        * But this should never happen.
+                        * it is saved and will be restored on
+                        * nilfs_transaction_commit().
                         */
                        printk(KERN_WARNING
                               "NILFS warning: journal info from a different "
@@ -195,7 +194,7 @@ static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
  *
  * nilfs_transaction_begin() acquires a reader/writer semaphore, called
  * the segment semaphore, to make a segment construction and write tasks
- * exclusive.  The function is used with nilfs_transaction_end() in pairs.
+ * exclusive.  The function is used with nilfs_transaction_commit() in pairs.
  * The region enclosed by these two functions can be nested.  To avoid a
  * deadlock, the semaphore is only acquired or released in the outermost call.
  *
@@ -212,8 +211,6 @@ static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
  *
  * %-ENOMEM - Insufficient memory available.
  *
- * %-ERESTARTSYS - Interrupted
- *
  * %-ENOSPC - No space left on device
  */
 int nilfs_transaction_begin(struct super_block *sb,
@@ -248,16 +245,17 @@ int nilfs_transaction_begin(struct super_block *sb,
 }
 
 /**
- * nilfs_transaction_end - end indivisible file operations.
+ * nilfs_transaction_commit - commit indivisible file operations.
  * @sb: super block
- * @commit: commit flag (0 for no change)
  *
- * nilfs_transaction_end() releases the read semaphore which is
- * acquired by nilfs_transaction_begin(). Its releasing is only done
- * in outermost call of this function. If the nilfs_transaction_info
- * was allocated dynamically, it is given back to a slab cache.
+ * nilfs_transaction_commit() releases the read semaphore which is
+ * acquired by nilfs_transaction_begin(). This is only performed
+ * in outermost call of this function.  If a commit flag is set,
+ * nilfs_transaction_commit() sets a timer to start the segment
+ * constructor.  If a sync flag is set, it starts construction
+ * directly.
  */
-int nilfs_transaction_end(struct super_block *sb, int commit)
+int nilfs_transaction_commit(struct super_block *sb)
 {
        struct nilfs_transaction_info *ti = current->journal_info;
        struct nilfs_sb_info *sbi;
@@ -265,9 +263,7 @@ int nilfs_transaction_end(struct super_block *sb, int commit)
        int err = 0;
 
        BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC);
-
-       if (commit)
-               ti->ti_flags |= NILFS_TI_COMMIT;
+       ti->ti_flags |= NILFS_TI_COMMIT;
        if (ti->ti_count > 0) {
                ti->ti_count--;
                return 0;
@@ -291,6 +287,22 @@ int nilfs_transaction_end(struct super_block *sb, int commit)
        return err;
 }
 
+void nilfs_transaction_abort(struct super_block *sb)
+{
+       struct nilfs_transaction_info *ti = current->journal_info;
+
+       BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC);
+       if (ti->ti_count > 0) {
+               ti->ti_count--;
+               return;
+       }
+       up_read(&NILFS_SB(sb)->s_nilfs->ns_segctor_sem);
+
+       current->journal_info = ti->ti_save;
+       if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC)
+               kmem_cache_free(nilfs_transaction_cachep, ti);
+}
+
 void nilfs_relax_pressure_in_lock(struct super_block *sb)
 {
        struct nilfs_sb_info *sbi = NILFS_SB(sb);
@@ -321,8 +333,7 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi,
 {
        struct nilfs_transaction_info *cur_ti = current->journal_info;
 
-       BUG_ON(cur_ti);
-       BUG_ON(!ti);
+       WARN_ON(cur_ti);
        ti->ti_flags = NILFS_TI_WRITER;
        ti->ti_count = 0;
        ti->ti_save = cur_ti;
@@ -533,8 +544,6 @@ static int nilfs_collect_file_data(struct nilfs_sc_info *sci,
 {
        int err;
 
-       /* BUG_ON(!buffer_dirty(bh)); */
-       /* excluded by scan_dirty_data_buffers() */
        err = nilfs_bmap_propagate(NILFS_I(inode)->i_bmap, bh);
        if (unlikely(err < 0))
                return nilfs_handle_bmap_error(err, __func__, inode,
@@ -553,8 +562,6 @@ static int nilfs_collect_file_node(struct nilfs_sc_info *sci,
 {
        int err;
 
-       /* BUG_ON(!buffer_dirty(bh)); */
-       /* excluded by scan_dirty_node_buffers() */
        err = nilfs_bmap_propagate(NILFS_I(inode)->i_bmap, bh);
        if (unlikely(err < 0))
                return nilfs_handle_bmap_error(err, __func__, inode,
@@ -566,7 +573,7 @@ static int nilfs_collect_file_bmap(struct nilfs_sc_info *sci,
                                   struct buffer_head *bh,
                                   struct inode *inode)
 {
-       BUG_ON(!buffer_dirty(bh));
+       WARN_ON(!buffer_dirty(bh));
        return nilfs_segctor_add_file_block(sci, bh, inode, sizeof(__le64));
 }
 
@@ -615,7 +622,7 @@ static int nilfs_collect_dat_data(struct nilfs_sc_info *sci,
 static int nilfs_collect_dat_bmap(struct nilfs_sc_info *sci,
                                  struct buffer_head *bh, struct inode *inode)
 {
-       BUG_ON(!buffer_dirty(bh));
+       WARN_ON(!buffer_dirty(bh));
        return nilfs_segctor_add_file_block(sci, bh, inode,
                                            sizeof(struct nilfs_binfo_dat));
 }
@@ -849,9 +856,9 @@ static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci)
                nilfs_mdt_mark_dirty(nilfs->ns_cpfile);
                nilfs_cpfile_put_checkpoint(
                        nilfs->ns_cpfile, nilfs->ns_cno, bh_cp);
-       } else {
-               BUG_ON(err == -EINVAL || err == -ENOENT);
-       }
+       } else
+               WARN_ON(err == -EINVAL || err == -ENOENT);
+
        return err;
 }
 
@@ -866,7 +873,7 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci)
        err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0,
                                          &raw_cp, &bh_cp);
        if (unlikely(err)) {
-               BUG_ON(err == -EINVAL || err == -ENOENT);
+               WARN_ON(err == -EINVAL || err == -ENOENT);
                goto failed_ibh;
        }
        raw_cp->cp_snapshot_list.ssl_next = 0;
@@ -879,8 +886,7 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci)
                cpu_to_le64(sci->sc_nblk_inc + sci->sc_nblk_this_inc);
        raw_cp->cp_create = cpu_to_le64(sci->sc_seg_ctime);
        raw_cp->cp_cno = cpu_to_le64(nilfs->ns_cno);
-       if (sci->sc_sketch_inode && i_size_read(sci->sc_sketch_inode) > 0)
-               nilfs_checkpoint_set_sketch(raw_cp);
+
        nilfs_write_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode, 1);
        nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, bh_cp);
        return 0;
@@ -915,11 +921,6 @@ static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci,
                nilfs_fill_in_file_bmap(ifile, ii);
                set_bit(NILFS_I_COLLECTED, &ii->i_state);
        }
-       if (sci->sc_sketch_inode) {
-               ii = NILFS_I(sci->sc_sketch_inode);
-               if (test_bit(NILFS_I_DIRTY, &ii->i_state))
-                       nilfs_fill_in_file_bmap(ifile, ii);
-       }
 }
 
 /*
@@ -931,7 +932,6 @@ static void nilfs_fill_in_super_root_crc(struct buffer_head *bh_sr, u32 seed)
                (struct nilfs_super_root *)bh_sr->b_data;
        u32 crc;
 
-       BUG_ON(NILFS_SR_BYTES > bh_sr->b_size);
        crc = crc32_le(seed,
                       (unsigned char *)raw_sr + sizeof(raw_sr->sr_sum),
                       NILFS_SR_BYTES - sizeof(raw_sr->sr_sum));
@@ -1009,8 +1009,7 @@ static void nilfs_segctor_cancel_free_segments(struct nilfs_sc_info *sci,
                if (!(ent->flags & NILFS_SLH_FREED))
                        break;
                err = nilfs_sufile_cancel_free(sufile, ent->segnum);
-               BUG_ON(err);
-
+               WARN_ON(err); /* do not happen */
                ent->flags &= ~NILFS_SLH_FREED;
        }
 }
@@ -1222,26 +1221,6 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                        sci->sc_stage.scnt = NILFS_ST_DONE;
                        return 0;
                }
-               sci->sc_stage.scnt++;  /* Fall through */
-       case NILFS_ST_SKETCH:
-               if (mode == SC_LSEG_SR && sci->sc_sketch_inode) {
-                       ii = NILFS_I(sci->sc_sketch_inode);
-                       if (test_bit(NILFS_I_DIRTY, &ii->i_state)) {
-                               sci->sc_sketch_inode->i_ctime.tv_sec
-                                       = sci->sc_seg_ctime;
-                               sci->sc_sketch_inode->i_mtime.tv_sec
-                                       = sci->sc_seg_ctime;
-                               err = nilfs_mark_inode_dirty(
-                                       sci->sc_sketch_inode);
-                               if (unlikely(err))
-                                       goto break_or_fail;
-                       }
-                       err = nilfs_segctor_scan_file(sci,
-                                                     sci->sc_sketch_inode,
-                                                     &nilfs_sc_file_ops);
-                       if (unlikely(err))
-                               goto break_or_fail;
-               }
                sci->sc_stage.scnt++;
                sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED;
                /* Fall through */
@@ -1459,7 +1438,7 @@ static int nilfs_segctor_extend_segments(struct nilfs_sc_info *sci,
  failed:
        list_for_each_entry_safe(segbuf, n, &list, sb_list) {
                ret = nilfs_sufile_free(sufile, segbuf->sb_nextnum);
-               BUG_ON(ret);
+               WARN_ON(ret); /* never fails */
                list_del_init(&segbuf->sb_list);
                nilfs_segbuf_free(segbuf);
        }
@@ -1475,7 +1454,7 @@ static void nilfs_segctor_free_incomplete_segments(struct nilfs_sc_info *sci,
        segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs);
        if (nilfs->ns_nextnum != segbuf->sb_nextnum) {
                ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum);
-               BUG_ON(ret);
+               WARN_ON(ret); /* never fails */
        }
        if (segbuf->sb_io_error) {
                /* Case 1: The first segment failed */
@@ -1491,7 +1470,7 @@ static void nilfs_segctor_free_incomplete_segments(struct nilfs_sc_info *sci,
 
        list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) {
                ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum);
-               BUG_ON(ret);
+               WARN_ON(ret); /* never fails */
                if (!done && segbuf->sb_io_error) {
                        if (segbuf->sb_segnum != nilfs->ns_nextnum)
                                /* Case 2: extended segment (!= next) failed */
@@ -1545,7 +1524,7 @@ static void nilfs_segctor_update_segusage(struct nilfs_sc_info *sci,
        list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) {
                ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum,
                                                     &raw_su, &bh_su);
-               BUG_ON(ret); /* always succeed because bh_su is dirty */
+               WARN_ON(ret); /* always succeed because bh_su is dirty */
                live_blocks = segbuf->sb_sum.nblocks +
                        (segbuf->sb_pseg_start - segbuf->sb_fseg_start);
                raw_su->su_lastmod = cpu_to_le64(sci->sc_seg_ctime);
@@ -1566,7 +1545,7 @@ static void nilfs_segctor_cancel_segusage(struct nilfs_sc_info *sci,
        segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs);
        ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum,
                                             &raw_su, &bh_su);
-       BUG_ON(ret); /* always succeed because bh_su is dirty */
+       WARN_ON(ret); /* always succeed because bh_su is dirty */
        raw_su->su_nblocks = cpu_to_le32(segbuf->sb_pseg_start -
                                         segbuf->sb_fseg_start);
        nilfs_sufile_put_segment_usage(sufile, segbuf->sb_segnum, bh_su);
@@ -1574,7 +1553,7 @@ static void nilfs_segctor_cancel_segusage(struct nilfs_sc_info *sci,
        list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) {
                ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum,
                                                     &raw_su, &bh_su);
-               BUG_ON(ret); /* always succeed */
+               WARN_ON(ret); /* always succeed */
                raw_su->su_nblocks = 0;
                nilfs_sufile_put_segment_usage(sufile, segbuf->sb_segnum,
                                               bh_su);
@@ -1593,7 +1572,7 @@ static void nilfs_segctor_truncate_segments(struct nilfs_sc_info *sci,
                list_del_init(&segbuf->sb_list);
                sci->sc_segbuf_nblocks -= segbuf->sb_rest_blocks;
                ret = nilfs_sufile_free(sufile, segbuf->sb_nextnum);
-               BUG_ON(ret);
+               WARN_ON(ret);
                nilfs_segbuf_free(segbuf);
        }
 }
@@ -1910,7 +1889,6 @@ static int nilfs_page_has_uncleared_buffer(struct page *page)
 
 static void __nilfs_end_page_io(struct page *page, int err)
 {
-       /* BUG_ON(err > 0); */
        if (!err) {
                if (!nilfs_page_buffers_clean(page))
                        __set_page_dirty_nobuffers(page);
@@ -2101,11 +2079,8 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
                nilfs_drop_collected_inodes(&sci->sc_gc_inodes);
                if (update_sr)
                        nilfs_commit_gcdat_inode(nilfs);
-       } else {
+       } else
                nilfs->ns_nongc_ctime = sci->sc_seg_ctime;
-               set_nilfs_cond_nongc_write(nilfs);
-               wake_up(&nilfs->ns_cleanerd_wq);
-       }
 
        sci->sc_nblk_inc += sci->sc_nblk_this_inc;
 
@@ -2219,13 +2194,6 @@ static void nilfs_segctor_reactivate_segments(struct nilfs_sc_info *sci,
                nilfs_segment_usage_set_active(ent->raw_su);
                nilfs_close_segment_entry(ent, sufile);
        }
-
-       down_write(&nilfs->ns_sem);
-       head = &nilfs->ns_used_segments;
-       list_for_each_entry(ent, head, list) {
-               nilfs_segment_usage_set_volatile_active(ent->raw_su);
-       }
-       up_write(&nilfs->ns_sem);
 }
 
 static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
@@ -2234,7 +2202,6 @@ static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
        struct nilfs_segment_buffer *segbuf, *last;
        struct nilfs_segment_entry *ent;
        struct inode *sufile = nilfs->ns_sufile;
-       struct list_head *head;
        int err;
 
        last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
@@ -2255,22 +2222,13 @@ static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
                BUG_ON(!buffer_dirty(ent->bh_su));
        }
 
-       head = &sci->sc_active_segments;
-       list_for_each_entry(ent, head, list) {
+       list_for_each_entry(ent, &sci->sc_active_segments, list) {
                err = nilfs_open_segment_entry(ent, sufile);
                if (unlikely(err))
                        goto failed;
                nilfs_segment_usage_clear_active(ent->raw_su);
-               BUG_ON(!buffer_dirty(ent->bh_su));
+               WARN_ON(!buffer_dirty(ent->bh_su));
        }
-
-       down_write(&nilfs->ns_sem);
-       head = &nilfs->ns_used_segments;
-       list_for_each_entry(ent, head, list) {
-               /* clear volatile active for segments of older generations */
-               nilfs_segment_usage_clear_volatile_active(ent->raw_su);
-       }
-       up_write(&nilfs->ns_sem);
        return 0;
 
  failed:
@@ -2294,19 +2252,15 @@ static void nilfs_segctor_bead_completed_segments(struct nilfs_sc_info *sci)
        }
 }
 
-static void
-__nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
-                                          struct the_nilfs *nilfs)
-
+static void nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
+                                                    struct the_nilfs *nilfs)
 {
-       struct nilfs_segment_entry *ent;
-
-       list_splice_init(&sci->sc_active_segments,
-                        nilfs->ns_used_segments.prev);
+       struct nilfs_segment_entry *ent, *n;
 
-       list_for_each_entry(ent, &nilfs->ns_used_segments, list) {
-               nilfs_segment_usage_set_volatile_active(ent->raw_su);
-               /* These segments are kept open */
+       list_for_each_entry_safe(ent, n, &sci->sc_active_segments, list) {
+               list_del(&ent->list);
+               nilfs_close_segment_entry(ent, nilfs->ns_sufile);
+               nilfs_free_segment_entry(ent);
        }
 }
 
@@ -2351,7 +2305,6 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
                /* Avoid empty segment */
                if (sci->sc_stage.scnt == NILFS_ST_DONE &&
                    NILFS_SEG_EMPTY(&sci->sc_curseg->sb_sum)) {
-                       BUG_ON(mode == SC_LSEG_SR);
                        nilfs_segctor_end_construction(sci, nilfs, 1);
                        goto out;
                }
@@ -2395,8 +2348,8 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
                if (has_sr) {
                        down_write(&nilfs->ns_sem);
                        nilfs_update_last_segment(sbi, 1);
-                       __nilfs_segctor_commit_deactivate_segments(sci, nilfs);
                        up_write(&nilfs->ns_sem);
+                       nilfs_segctor_commit_deactivate_segments(sci, nilfs);
                        nilfs_segctor_commit_free_segments(sci);
                        nilfs_segctor_clear_metadata_dirty(sci);
                }
@@ -2405,13 +2358,6 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
 
        } while (sci->sc_stage.scnt != NILFS_ST_DONE);
 
-       /* Clearing sketch data */
-       if (has_sr && sci->sc_sketch_inode) {
-               if (i_size_read(sci->sc_sketch_inode) == 0)
-                       clear_bit(NILFS_I_DIRTY,
-                                 &NILFS_I(sci->sc_sketch_inode)->i_state);
-               i_size_write(sci->sc_sketch_inode, 0);
-       }
  out:
        nilfs_segctor_destroy_segment_buffers(sci);
        nilfs_segctor_check_out_files(sci, sbi);
@@ -2490,9 +2436,8 @@ int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *sci,
        struct inode *sufile = nilfs->ns_sufile;
        LIST_HEAD(list);
        __u64 *pnum;
-       const char *flag_name;
        size_t i;
-       int err, err2 = 0;
+       int err;
 
        for (pnum = segnum, i = 0; i < nsegs; pnum++, i++) {
                ent = nilfs_alloc_segment_entry(*pnum);
@@ -2506,32 +2451,12 @@ int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *sci,
                if (unlikely(err))
                        goto failed;
 
-               if (unlikely(le32_to_cpu(ent->raw_su->su_flags) !=
-                            (1UL << NILFS_SEGMENT_USAGE_DIRTY))) {
-                       if (nilfs_segment_usage_clean(ent->raw_su))
-                               flag_name = "clean";
-                       else if (nilfs_segment_usage_active(ent->raw_su))
-                               flag_name = "active";
-                       else if (nilfs_segment_usage_volatile_active(
-                                        ent->raw_su))
-                               flag_name = "volatile active";
-                       else if (!nilfs_segment_usage_dirty(ent->raw_su))
-                               flag_name = "non-dirty";
-                       else
-                               flag_name = "erroneous";
-
-                       printk(KERN_ERR
-                              "NILFS: %s segment is requested to be cleaned "
-                              "(segnum=%llu)\n",
-                              flag_name, (unsigned long long)ent->segnum);
-                       err2 = -EINVAL;
-               }
+               if (unlikely(!nilfs_segment_usage_dirty(ent->raw_su)))
+                       printk(KERN_WARNING "NILFS: unused segment is "
+                              "requested to be cleaned (segnum=%llu)\n",
+                              (unsigned long long)ent->segnum);
                nilfs_close_segment_entry(ent, sufile);
        }
-       if (unlikely(err2)) {
-               err = err2;
-               goto failed;
-       }
        list_splice(&list, sci->sc_cleaning_segments.prev);
        return 0;
 
@@ -2716,8 +2641,6 @@ struct nilfs_segctor_req {
 static void nilfs_segctor_accept(struct nilfs_sc_info *sci,
                                 struct nilfs_segctor_req *req)
 {
-       BUG_ON(!sci);
-
        req->sc_err = req->sb_err = 0;
        spin_lock(&sci->sc_state_lock);
        req->seq_accepted = sci->sc_seq_request;
@@ -3014,11 +2937,6 @@ static int nilfs_segctor_init(struct nilfs_sc_info *sci,
                              struct nilfs_recovery_info *ri)
 {
        int err;
-       struct inode *inode = nilfs_iget(sci->sc_super, NILFS_SKETCH_INO);
-
-       sci->sc_sketch_inode = IS_ERR(inode) ? NULL : inode;
-       if (sci->sc_sketch_inode)
-               i_size_write(sci->sc_sketch_inode, 0);
 
        sci->sc_seq_done = sci->sc_seq_request;
        if (ri)
@@ -3030,10 +2948,6 @@ static int nilfs_segctor_init(struct nilfs_sc_info *sci,
                if (ri)
                        list_splice_init(&sci->sc_active_segments,
                                         ri->ri_used_segments.prev);
-               if (sci->sc_sketch_inode) {
-                       iput(sci->sc_sketch_inode);
-                       sci->sc_sketch_inode = NULL;
-               }
        }
        return err;
 }
@@ -3118,7 +3032,7 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci)
        if (flag || nilfs_segctor_confirm(sci))
                nilfs_segctor_write_out(sci);
 
-       BUG_ON(!list_empty(&sci->sc_copied_buffers));
+       WARN_ON(!list_empty(&sci->sc_copied_buffers));
 
        if (!list_empty(&sci->sc_dirty_files)) {
                nilfs_warning(sbi->s_super, __func__,
@@ -3131,12 +3045,8 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci)
        if (!list_empty(&sci->sc_cleaning_segments))
                nilfs_dispose_segment_list(&sci->sc_cleaning_segments);
 
-       BUG_ON(!list_empty(&sci->sc_segbufs));
+       WARN_ON(!list_empty(&sci->sc_segbufs));
 
-       if (sci->sc_sketch_inode) {
-               iput(sci->sc_sketch_inode);
-               sci->sc_sketch_inode = NULL;
-       }
        down_write(&sbi->s_nilfs->ns_segctor_sem);
 
        kfree(sci);