对数据块的分配


#define NEXT_FREE_BLKADDR(sbi, curseg)                                  \
        (START_BLOCK(sbi, (curseg)->segno) + (curseg)->next_blkoff)

.....

void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
                block_t old_blkaddr, block_t *new_blkaddr,
                struct f2fs_summary *sum, int type,
                struct f2fs_io_info *fio, bool add_list)
{
        struct sit_info *sit_i = SIT_I(sbi);
        struct curseg_info *curseg = CURSEG_I(sbi, type);

        down_read(&SM_I(sbi)->curseg_lock);

        mutex_lock(&curseg->curseg_mutex);
        down_write(&sit_i->sentry_lock);

        *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);

        f2fs_wait_discard_bio(sbi, *new_blkaddr);

                ....