Skip to content

Commit 5004036

Browse files
Jaegeuk Kimpundiramit
authored andcommitted
f2fs: clean up flush/discard command namings
commit b01a92019cac30398ef75b560d2668b399f4e393 upstream. This patch simply cleans up the names for flush/discard commands. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 1a50ad0 commit 5004036

3 files changed

Lines changed: 59 additions & 61 deletions

File tree

fs/f2fs/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
194194
si->cache_mem += sizeof(struct f2fs_gc_kthread);
195195

196196
/* build merge flush thread */
197-
if (SM_I(sbi)->cmd_control_info)
197+
if (SM_I(sbi)->fcc_info)
198198
si->cache_mem += sizeof(struct flush_cmd_control);
199199

200200
/* free nids */

fs/f2fs/f2fs.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,12 @@ struct discard_entry {
248248
int len; /* # of consecutive blocks of the discard */
249249
};
250250

251-
struct bio_entry {
252-
struct list_head list;
253-
block_t lstart;
254-
block_t len;
255-
struct bio *bio;
256-
struct completion event;
257-
int error;
251+
struct discard_cmd {
252+
struct list_head list; /* command list */
253+
struct completion wait; /* compleation */
254+
block_t lstart; /* logical start address */
255+
block_t len; /* length */
256+
struct bio *bio; /* bio */
258257
};
259258

260259
/* for the list of fsync inodes, used only during recovery */
@@ -701,8 +700,8 @@ struct f2fs_sm_info {
701700
unsigned int rec_prefree_segments;
702701

703702
/* for small discard management */
704-
struct list_head discard_list; /* 4KB discard list */
705-
struct list_head wait_list; /* linked with issued discard bio */
703+
struct list_head discard_entry_list; /* 4KB discard entry list */
704+
struct list_head discard_cmd_list; /* discard cmd list */
706705
int nr_discards; /* # of discards in the list */
707706
int max_discards; /* max. discards to be issued */
708707

@@ -716,8 +715,7 @@ struct f2fs_sm_info {
716715
unsigned int min_fsync_blocks; /* threshold for fsync */
717716

718717
/* for flush command control */
719-
struct flush_cmd_control *cmd_control_info;
720-
718+
struct flush_cmd_control *fcc_info;
721719
};
722720

723721
/*

fs/f2fs/segment.c

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define __reverse_ffz(x) __reverse_ffs(~(x))
2727

2828
static struct kmem_cache *discard_entry_slab;
29-
static struct kmem_cache *bio_entry_slab;
29+
static struct kmem_cache *discard_cmd_slab;
3030
static struct kmem_cache *sit_entry_set_slab;
3131
static struct kmem_cache *inmem_entry_slab;
3232

@@ -439,7 +439,7 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi)
439439
static int issue_flush_thread(void *data)
440440
{
441441
struct f2fs_sb_info *sbi = data;
442-
struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info;
442+
struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
443443
wait_queue_head_t *q = &fcc->flush_wait_queue;
444444
repeat:
445445
if (kthread_should_stop())
@@ -468,7 +468,7 @@ static int issue_flush_thread(void *data)
468468

469469
int f2fs_issue_flush(struct f2fs_sb_info *sbi)
470470
{
471-
struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info;
471+
struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
472472
struct flush_cmd cmd;
473473

474474
trace_f2fs_issue_flush(sbi->sb, test_opt(sbi, NOBARRIER),
@@ -511,8 +511,8 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
511511
struct flush_cmd_control *fcc;
512512
int err = 0;
513513

514-
if (SM_I(sbi)->cmd_control_info) {
515-
fcc = SM_I(sbi)->cmd_control_info;
514+
if (SM_I(sbi)->fcc_info) {
515+
fcc = SM_I(sbi)->fcc_info;
516516
goto init_thread;
517517
}
518518

@@ -522,14 +522,14 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
522522
atomic_set(&fcc->submit_flush, 0);
523523
init_waitqueue_head(&fcc->flush_wait_queue);
524524
init_llist_head(&fcc->issue_list);
525-
SM_I(sbi)->cmd_control_info = fcc;
525+
SM_I(sbi)->fcc_info = fcc;
526526
init_thread:
527527
fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
528528
"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
529529
if (IS_ERR(fcc->f2fs_issue_flush)) {
530530
err = PTR_ERR(fcc->f2fs_issue_flush);
531531
kfree(fcc);
532-
SM_I(sbi)->cmd_control_info = NULL;
532+
SM_I(sbi)->fcc_info = NULL;
533533
return err;
534534
}
535535

@@ -538,7 +538,7 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
538538

539539
void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
540540
{
541-
struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info;
541+
struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
542542

543543
if (fcc && fcc->f2fs_issue_flush) {
544544
struct task_struct *flush_thread = fcc->f2fs_issue_flush;
@@ -548,7 +548,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
548548
}
549549
if (free) {
550550
kfree(fcc);
551-
SM_I(sbi)->cmd_control_info = NULL;
551+
SM_I(sbi)->fcc_info = NULL;
552552
}
553553
}
554554

@@ -628,42 +628,43 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
628628
mutex_unlock(&dirty_i->seglist_lock);
629629
}
630630

631-
static struct bio_entry *__add_bio_entry(struct f2fs_sb_info *sbi,
631+
static struct discard_cmd *__add_discard_cmd(struct f2fs_sb_info *sbi,
632632
struct bio *bio, block_t lstart, block_t len)
633633
{
634-
struct list_head *wait_list = &(SM_I(sbi)->wait_list);
635-
struct bio_entry *be = f2fs_kmem_cache_alloc(bio_entry_slab, GFP_NOFS);
634+
struct list_head *wait_list = &(SM_I(sbi)->discard_cmd_list);
635+
struct discard_cmd *dc;
636636

637-
INIT_LIST_HEAD(&be->list);
638-
be->bio = bio;
639-
be->lstart = lstart;
640-
be->len = len;
641-
init_completion(&be->event);
642-
list_add_tail(&be->list, wait_list);
637+
dc = f2fs_kmem_cache_alloc(discard_cmd_slab, GFP_NOFS);
638+
INIT_LIST_HEAD(&dc->list);
639+
dc->bio = bio;
640+
dc->lstart = lstart;
641+
dc->len = len;
642+
init_completion(&dc->wait);
643+
list_add_tail(&dc->list, wait_list);
643644

644-
return be;
645+
return dc;
645646
}
646647

647648
/* This should be covered by global mutex, &sit_i->sentry_lock */
648649
void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
649650
{
650-
struct list_head *wait_list = &(SM_I(sbi)->wait_list);
651-
struct bio_entry *be, *tmp;
651+
struct list_head *wait_list = &(SM_I(sbi)->discard_cmd_list);
652+
struct discard_cmd *dc, *tmp;
652653

653-
list_for_each_entry_safe(be, tmp, wait_list, list) {
654-
struct bio *bio = be->bio;
654+
list_for_each_entry_safe(dc, tmp, wait_list, list) {
655+
struct bio *bio = dc->bio;
655656
int err;
656657

657-
if (!completion_done(&be->event)) {
658-
if ((be->lstart <= blkaddr &&
659-
blkaddr < be->lstart + be->len) ||
658+
if (!completion_done(&dc->wait)) {
659+
if ((dc->lstart <= blkaddr &&
660+
blkaddr < dc->lstart + dc->len) ||
660661
blkaddr == NULL_ADDR)
661-
wait_for_completion_io(&be->event);
662+
wait_for_completion_io(&dc->wait);
662663
else
663664
continue;
664665
}
665666

666-
err = be->error;
667+
err = bio->bi_error;
667668
if (err == -EOPNOTSUPP)
668669
err = 0;
669670

@@ -672,17 +673,16 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
672673
"Issue discard failed, ret: %d", err);
673674

674675
bio_put(bio);
675-
list_del(&be->list);
676-
kmem_cache_free(bio_entry_slab, be);
676+
list_del(&dc->list);
677+
kmem_cache_free(discard_cmd_slab, dc);
677678
}
678679
}
679680

680-
static void f2fs_submit_bio_wait_endio(struct bio *bio)
681+
static void f2fs_submit_discard_endio(struct bio *bio)
681682
{
682-
struct bio_entry *be = (struct bio_entry *)bio->bi_private;
683+
struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
683684

684-
be->error = bio->bi_error;
685-
complete(&be->event);
685+
complete(&dc->wait);
686686
}
687687

688688
/* copied from block/blk-lib.c in 4.10-rc1 */
@@ -786,11 +786,11 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
786786
SECTOR_FROM_BLOCK(blklen),
787787
GFP_NOFS, 0, &bio);
788788
if (!err && bio) {
789-
struct bio_entry *be = __add_bio_entry(sbi, bio,
789+
struct discard_cmd *dc = __add_discard_cmd(sbi, bio,
790790
lblkstart, blklen);
791791

792-
bio->bi_private = be;
793-
bio->bi_end_io = f2fs_submit_bio_wait_endio;
792+
bio->bi_private = dc;
793+
bio->bi_end_io = f2fs_submit_discard_endio;
794794
submit_bio(REQ_SYNC, bio);
795795
}
796796
return err;
@@ -897,7 +897,7 @@ static void __add_discard_entry(struct f2fs_sb_info *sbi,
897897
struct cp_control *cpc, struct seg_entry *se,
898898
unsigned int start, unsigned int end)
899899
{
900-
struct list_head *head = &SM_I(sbi)->discard_list;
900+
struct list_head *head = &SM_I(sbi)->discard_entry_list;
901901
struct discard_entry *new, *last;
902902

903903
if (!list_empty(head)) {
@@ -966,7 +966,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
966966

967967
void release_discard_addrs(struct f2fs_sb_info *sbi)
968968
{
969-
struct list_head *head = &(SM_I(sbi)->discard_list);
969+
struct list_head *head = &(SM_I(sbi)->discard_entry_list);
970970
struct discard_entry *entry, *this;
971971

972972
/* drop caches */
@@ -992,7 +992,7 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
992992

993993
void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
994994
{
995-
struct list_head *head = &(SM_I(sbi)->discard_list);
995+
struct list_head *head = &(SM_I(sbi)->discard_entry_list);
996996
struct discard_entry *entry, *this;
997997
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
998998
struct blk_plug plug;
@@ -2783,8 +2783,8 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
27832783
sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
27842784
sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
27852785

2786-
INIT_LIST_HEAD(&sm_info->discard_list);
2787-
INIT_LIST_HEAD(&sm_info->wait_list);
2786+
INIT_LIST_HEAD(&sm_info->discard_entry_list);
2787+
INIT_LIST_HEAD(&sm_info->discard_cmd_list);
27882788
sm_info->nr_discards = 0;
27892789
sm_info->max_discards = 0;
27902790

@@ -2934,15 +2934,15 @@ int __init create_segment_manager_caches(void)
29342934
if (!discard_entry_slab)
29352935
goto fail;
29362936

2937-
bio_entry_slab = f2fs_kmem_cache_create("bio_entry",
2938-
sizeof(struct bio_entry));
2939-
if (!bio_entry_slab)
2937+
discard_cmd_slab = f2fs_kmem_cache_create("discard_cmd",
2938+
sizeof(struct discard_cmd));
2939+
if (!discard_cmd_slab)
29402940
goto destroy_discard_entry;
29412941

29422942
sit_entry_set_slab = f2fs_kmem_cache_create("sit_entry_set",
29432943
sizeof(struct sit_entry_set));
29442944
if (!sit_entry_set_slab)
2945-
goto destroy_bio_entry;
2945+
goto destroy_discard_cmd;
29462946

29472947
inmem_entry_slab = f2fs_kmem_cache_create("inmem_page_entry",
29482948
sizeof(struct inmem_pages));
@@ -2952,8 +2952,8 @@ int __init create_segment_manager_caches(void)
29522952

29532953
destroy_sit_entry_set:
29542954
kmem_cache_destroy(sit_entry_set_slab);
2955-
destroy_bio_entry:
2956-
kmem_cache_destroy(bio_entry_slab);
2955+
destroy_discard_cmd:
2956+
kmem_cache_destroy(discard_cmd_slab);
29572957
destroy_discard_entry:
29582958
kmem_cache_destroy(discard_entry_slab);
29592959
fail:
@@ -2963,7 +2963,7 @@ int __init create_segment_manager_caches(void)
29632963
void destroy_segment_manager_caches(void)
29642964
{
29652965
kmem_cache_destroy(sit_entry_set_slab);
2966-
kmem_cache_destroy(bio_entry_slab);
2966+
kmem_cache_destroy(discard_cmd_slab);
29672967
kmem_cache_destroy(discard_entry_slab);
29682968
kmem_cache_destroy(inmem_entry_slab);
29692969
}

0 commit comments

Comments
 (0)