nilfs2: do not return io error for bio allocation failure
[safe/jmp/linux-2.6] / fs / nilfs2 / segbuf.c
index 3d3ea83..c71b689 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/crc32.h>
 #include "page.h"
 #include "segbuf.h"
-#include "seglist.h"
 
 
 static struct kmem_cache *nilfs_segbuf_cachep;
@@ -64,27 +63,17 @@ struct nilfs_segment_buffer *nilfs_segbuf_new(struct super_block *sb)
        INIT_LIST_HEAD(&segbuf->sb_list);
        INIT_LIST_HEAD(&segbuf->sb_segsum_buffers);
        INIT_LIST_HEAD(&segbuf->sb_payload_buffers);
-       segbuf->sb_segent = NULL;
        return segbuf;
 }
 
 void nilfs_segbuf_free(struct nilfs_segment_buffer *segbuf)
 {
-       struct nilfs_segment_entry *ent = segbuf->sb_segent;
-
-       if (ent != NULL && list_empty(&ent->list)) {
-               /* free isolated segment list head */
-               nilfs_free_segment_entry(segbuf->sb_segent);
-               segbuf->sb_segent = NULL;
-       }
        kmem_cache_free(nilfs_segbuf_cachep, segbuf);
 }
 
-int nilfs_segbuf_map(struct nilfs_segment_buffer *segbuf, __u64 segnum,
+void nilfs_segbuf_map(struct nilfs_segment_buffer *segbuf, __u64 segnum,
                     unsigned long offset, struct the_nilfs *nilfs)
 {
-       struct nilfs_segment_entry *ent;
-
        segbuf->sb_segnum = segnum;
        nilfs_get_segment_range(nilfs, segnum, &segbuf->sb_fseg_start,
                                &segbuf->sb_fseg_end);
@@ -92,18 +81,6 @@ int nilfs_segbuf_map(struct nilfs_segment_buffer *segbuf, __u64 segnum,
        segbuf->sb_pseg_start = segbuf->sb_fseg_start + offset;
        segbuf->sb_rest_blocks =
                segbuf->sb_fseg_end - segbuf->sb_pseg_start + 1;
-
-       /* Attach a segment list head */
-       ent = segbuf->sb_segent;
-       if (ent == NULL) {
-               segbuf->sb_segent = nilfs_alloc_segment_entry(segnum);
-               if (unlikely(!segbuf->sb_segent))
-                       return -ENOMEM;
-       } else {
-               BUG_ON(ent->bh_su || !list_empty(&ent->list));
-               ent->segnum = segnum;
-       }
-       return 0;
 }
 
 void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *segbuf,
@@ -339,10 +316,10 @@ static struct bio *nilfs_alloc_seg_bio(struct super_block *sb, sector_t start,
 {
        struct bio *bio;
 
-       bio = bio_alloc(GFP_NOWAIT, nr_vecs);
+       bio = bio_alloc(GFP_NOIO, nr_vecs);
        if (bio == NULL) {
                while (!bio && (nr_vecs >>= 1))
-                       bio = bio_alloc(GFP_NOWAIT, nr_vecs);
+                       bio = bio_alloc(GFP_NOIO, nr_vecs);
        }
        if (likely(bio)) {
                bio->bi_bdev = sb->s_bdev;
@@ -397,7 +374,7 @@ int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
                       struct nilfs_write_info *wi)
 {
        struct buffer_head *bh;
-       int res, rw = WRITE;
+       int res = 0, rw = WRITE;
 
        list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) {
                res = nilfs_submit_bh(wi, bh, rw);
@@ -416,19 +393,12 @@ int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
                 * Last BIO is always sent through the following
                 * submission.
                 */
-               rw |= (1 << BIO_RW_SYNCIO);
+               rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
                res = nilfs_submit_seg_bio(wi, rw);
-               if (unlikely(res))
-                       goto failed_bio;
        }
 
-       res = 0;
- out:
-       return res;
-
  failed_bio:
-       atomic_inc(&wi->err);
-       goto out;
+       return res;
 }
 
 /**