Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / fs / nilfs2 / segment.c
index e78b68a..bedcae2 100644 (file)
@@ -150,7 +150,8 @@ static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int);
 #define nilfs_cnt32_lt(a, b)  nilfs_cnt32_gt(b, a)
 #define nilfs_cnt32_le(a, b)  nilfs_cnt32_ge(b, a)
 
-static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
+static int nilfs_prepare_segment_lock(struct super_block *sb,
+                                     struct nilfs_transaction_info *ti)
 {
        struct nilfs_transaction_info *cur_ti = current->journal_info;
        void *save = NULL;
@@ -164,8 +165,7 @@ static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
                 * it is saved and will be restored on
                 * nilfs_transaction_commit().
                 */
-               printk(KERN_WARNING
-                      "NILFS warning: journal info from a different FS\n");
+               nilfs_msg(sb, KERN_WARNING, "journal info from a different FS");
                save = current->journal_info;
        }
        if (!ti) {
@@ -215,7 +215,7 @@ int nilfs_transaction_begin(struct super_block *sb,
                            int vacancy_check)
 {
        struct the_nilfs *nilfs;
-       int ret = nilfs_prepare_segment_lock(ti);
+       int ret = nilfs_prepare_segment_lock(sb, ti);
        struct nilfs_transaction_info *trace_ti;
 
        if (unlikely(ret < 0))
@@ -373,7 +373,7 @@ static void nilfs_transaction_lock(struct super_block *sb,
                nilfs_segctor_do_immediate_flush(sci);
 
                up_write(&nilfs->ns_segctor_sem);
-               yield();
+               cond_resched();
        }
        if (gcflag)
                ti->ti_flags |= NILFS_TI_GC;
@@ -1858,11 +1858,11 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
                 */
                list_for_each_entry(bh, &segbuf->sb_payload_buffers,
                                    b_assoc_buffers) {
-                       const unsigned long set_bits = (1 << BH_Uptodate);
+                       const unsigned long set_bits = BIT(BH_Uptodate);
                        const unsigned long clear_bits =
-                               (1 << BH_Dirty | 1 << BH_Async_Write |
-                                1 << BH_Delay | 1 << BH_NILFS_Volatile |
-                                1 << BH_NILFS_Redirected);
+                               (BIT(BH_Dirty) | BIT(BH_Async_Write) |
+                                BIT(BH_Delay) | BIT(BH_NILFS_Volatile) |
+                                BIT(BH_NILFS_Redirected));
 
                        set_mask_bits(&bh->b_state, clear_bits, set_bits);
                        if (bh == segbuf->sb_super_root) {
@@ -1951,8 +1951,9 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci,
                        err = nilfs_ifile_get_inode_block(
                                ifile, ii->vfs_inode.i_ino, &ibh);
                        if (unlikely(err)) {
-                               nilfs_warning(sci->sc_super, __func__,
-                                             "failed to get inode block.");
+                               nilfs_msg(sci->sc_super, KERN_WARNING,
+                                         "log writer: error %d getting inode block (ino=%lu)",
+                                         err, ii->vfs_inode.i_ino);
                                return err;
                        }
                        mark_buffer_dirty(ibh);
@@ -2131,10 +2132,10 @@ static void nilfs_segctor_start_timer(struct nilfs_sc_info *sci)
 static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn)
 {
        spin_lock(&sci->sc_state_lock);
-       if (!(sci->sc_flush_request & (1 << bn))) {
+       if (!(sci->sc_flush_request & BIT(bn))) {
                unsigned long prev_req = sci->sc_flush_request;
 
-               sci->sc_flush_request |= (1 << bn);
+               sci->sc_flush_request |= BIT(bn);
                if (!prev_req)
                        wake_up(&sci->sc_wait_daemon);
        }
@@ -2318,7 +2319,7 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
 }
 
 #define FLUSH_FILE_BIT (0x1) /* data file only */
-#define FLUSH_DAT_BIT  (1 << NILFS_DAT_INO) /* DAT only */
+#define FLUSH_DAT_BIT  BIT(NILFS_DAT_INO) /* DAT only */
 
 /**
  * nilfs_segctor_accept - record accepted sequence count of log-write requests
@@ -2458,8 +2459,7 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
                if (likely(!err))
                        break;
 
-               nilfs_warning(sb, __func__,
-                             "segment construction failed. (err=%d)", err);
+               nilfs_msg(sb, KERN_WARNING, "error %d cleaning segments", err);
                set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(sci->sc_interval);
        }
@@ -2467,9 +2467,9 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
                int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs,
                                                 sci->sc_nfreesegs);
                if (ret) {
-                       printk(KERN_WARNING
-                              "NILFS warning: error %d on discard request, "
-                              "turning discards off for the device\n", ret);
+                       nilfs_msg(sb, KERN_WARNING,
+                                 "error %d on discard request, turning discards off for the device",
+                                 ret);
                        nilfs_clear_opt(nilfs, DISCARD);
                }
        }
@@ -2551,10 +2551,9 @@ static int nilfs_segctor_thread(void *arg)
        /* start sync. */
        sci->sc_task = current;
        wake_up(&sci->sc_wait_task); /* for nilfs_segctor_start_thread() */
-       printk(KERN_INFO
-              "segctord starting. Construction interval = %lu seconds, "
-              "CP frequency < %lu seconds\n",
-              sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ);
+       nilfs_msg(sci->sc_super, KERN_INFO,
+                 "segctord starting. Construction interval = %lu seconds, CP frequency < %lu seconds",
+                 sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ);
 
        spin_lock(&sci->sc_state_lock);
  loop:
@@ -2628,8 +2627,8 @@ static int nilfs_segctor_start_thread(struct nilfs_sc_info *sci)
        if (IS_ERR(t)) {
                int err = PTR_ERR(t);
 
-               printk(KERN_ERR "NILFS: error %d creating segctord thread\n",
-                      err);
+               nilfs_msg(sci->sc_super, KERN_ERR,
+                         "error %d creating segctord thread", err);
                return err;
        }
        wait_event(sci->sc_wait_task, sci->sc_task != NULL);
@@ -2739,14 +2738,14 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci)
                nilfs_segctor_write_out(sci);
 
        if (!list_empty(&sci->sc_dirty_files)) {
-               nilfs_warning(sci->sc_super, __func__,
-                             "dirty file(s) after the final construction");
+               nilfs_msg(sci->sc_super, KERN_WARNING,
+                         "disposed unprocessed dirty file(s) when stopping log writer");
                nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1);
        }
 
        if (!list_empty(&sci->sc_iput_queue)) {
-               nilfs_warning(sci->sc_super, __func__,
-                             "iput queue is not empty");
+               nilfs_msg(sci->sc_super, KERN_WARNING,
+                         "disposed unprocessed inode(s) in iput queue when stopping log writer");
                nilfs_dispose_list(nilfs, &sci->sc_iput_queue, 1);
        }
 
@@ -2822,8 +2821,8 @@ void nilfs_detach_log_writer(struct super_block *sb)
        spin_lock(&nilfs->ns_inode_lock);
        if (!list_empty(&nilfs->ns_dirty_files)) {
                list_splice_init(&nilfs->ns_dirty_files, &garbage_list);
-               nilfs_warning(sb, __func__,
-                             "Hit dirty file after stopped log writer");
+               nilfs_msg(sb, KERN_WARNING,
+                         "disposed unprocessed dirty file(s) when detaching log writer");
        }
        spin_unlock(&nilfs->ns_inode_lock);
        up_write(&nilfs->ns_segctor_sem);