Skip to content

Commit

Permalink
f2fs: rewrite f2fs_bio_alloc to make it simpler
Browse files Browse the repository at this point in the history
Since, GFP_NOFS(__GFP_WAIT) is used for allocation requests of bio in f2fs.
So, there is no chance of returning NULL from the BIO allocation.

Making the bio allocation routine for f2fs simpler.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
  • Loading branch information
Namjae Jeon authored and Jaegeuk Kim committed Dec 11, 2012
1 parent d08ab08 commit c212991
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,28 +647,18 @@ struct bio *f2fs_bio_alloc(struct block_device *bdev, sector_t first_sector,
int nr_vecs, gfp_t gfp_flags)
{
struct bio *bio;
repeat:

/* allocate new bio */
bio = bio_alloc(gfp_flags, nr_vecs);

if (bio == NULL && (current->flags & PF_MEMALLOC)) {
while (!bio && (nr_vecs /= 2))
bio = bio_alloc(gfp_flags, nr_vecs);
}
if (bio) {
bio->bi_bdev = bdev;
bio->bi_sector = first_sector;
bio->bi_bdev = bdev;
bio->bi_sector = first_sector;
retry:
bio->bi_private = kmalloc(sizeof(struct bio_private),
GFP_NOFS | __GFP_HIGH);
if (!bio->bi_private) {
cond_resched();
goto retry;
}
}
if (bio == NULL) {
bio->bi_private = kmalloc(sizeof(struct bio_private),
GFP_NOFS | __GFP_HIGH);
if (!bio->bi_private) {
cond_resched();
goto repeat;
goto retry;
}
return bio;
}
Expand Down

0 comments on commit c212991

Please sign in to comment.