From: Theodore Ts'o Date: Fri, 8 Nov 2019 21:03:38 +0000 (-0500) Subject: Convert kernel compat functions to use new ll_rw_block() function signature X-Git-Tag: v1.46.0~98 X-Git-Url: https://git.whamcloud.com/?p=tools%2Fe2fsprogs.git;a=commitdiff_plain;h=db113c0e76826d621dfc5ee968ccbbe2127363a6 Convert kernel compat functions to use new ll_rw_block() function signature In newer kernels, ll_rw_block() separated the request operation and the operational flags arguments. This means adding a new parameter to ll_rw_block() (which is ignored in our compat layer) and changing READ and WRITE to REQ_OP_READ and REQ_OP_WRITE, respectively. This makes it easier to keep us in sync with the kernel tree. Signed-off-by: Theodore Ts'o --- diff --git a/debugfs/do_journal.c b/debugfs/do_journal.c index eeb363e..88b1606 100644 --- a/debugfs/do_journal.c +++ b/debugfs/do_journal.c @@ -105,7 +105,7 @@ static errcode_t journal_commit_trans(journal_transaction_t *trans) if (err) goto error; mark_buffer_uptodate(cbh, 0); - ll_rw_block(READ, 1, &cbh); + ll_rw_block(REQ_OP_READ, 0, 1, &cbh); err = cbh->b_err; if (err) goto error; @@ -140,7 +140,7 @@ static errcode_t journal_commit_trans(journal_transaction_t *trans) dbg_printf("Writing commit block at %llu:%llu\n", trans->block, bh->b_blocknr); mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); err = bh->b_err; if (err) goto error; @@ -213,7 +213,7 @@ static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans, dbg_printf("Writing revoke block at %llu:%llu\n", curr_blk, bh->b_blocknr); mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); err = bh->b_err; if (err) goto error; @@ -247,7 +247,7 @@ static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans, dbg_printf("Writing revoke block at %llu:%llu\n", curr_blk, bh->b_blocknr); mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); err = bh->b_err; if (err) goto error; @@ -329,7 +329,7 @@ static errcode_t journal_add_blocks_to_trans(journal_transaction_t *trans, dbg_printf("Writing descriptor block at %llu:%llu\n", jdb_blk, bh->b_blocknr); mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); err = bh->b_err; if (err) goto error; @@ -376,7 +376,7 @@ static errcode_t journal_add_blocks_to_trans(journal_transaction_t *trans, block_list[i], curr_blk, data_bh->b_blocknr, tag_bytes); mark_buffer_dirty(data_bh); - ll_rw_block(WRITE, 1, &data_bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &data_bh); err = data_bh->b_err; if (err) goto error; @@ -394,7 +394,7 @@ static errcode_t journal_add_blocks_to_trans(journal_transaction_t *trans, dbg_printf("Writing descriptor block at %llu:%llu\n", jdb_blk, bh->b_blocknr); mark_buffer_dirty(bh); - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); err = bh->b_err; if (err) goto error; @@ -691,7 +691,7 @@ static errcode_t journal_find_head(journal_t *journal) if (err) goto err; mark_buffer_uptodate(bh, 0); - ll_rw_block(READ, 1, &bh); + ll_rw_block(REQ_OP_READ, 0, 1, &bh); err = bh->b_err; if (err) goto err; diff --git a/debugfs/journal.c b/debugfs/journal.c index c16daa5..023399e 100644 --- a/debugfs/journal.c +++ b/debugfs/journal.c @@ -162,14 +162,14 @@ int sync_blockdev(kdev_t kdev) return io_channel_flush(io) ? EIO : 0; } -void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) +void ll_rw_block(int rw, int op_flags, int nr, struct buffer_head *bhp[]) { errcode_t retval; struct buffer_head *bh; for (; nr > 0; --nr) { bh = *bhp++; - if (rw == READ && !bh->b_uptodate) { + if (rw == REQ_OP_READ && !bh->b_uptodate) { jfs_debug(3, "reading block %llu/%p\n", bh->b_blocknr, (void *) bh); retval = io_channel_read_blk64(bh->b_io, @@ -183,7 +183,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) continue; } bh->b_uptodate = 1; - } else if (rw == WRITE && bh->b_dirty) { + } else if (rw == REQ_OP_WRITE && bh->b_dirty) { jfs_debug(3, "writing block %llu/%p\n", bh->b_blocknr, (void *) bh); @@ -201,7 +201,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) bh->b_uptodate = 1; } else { jfs_debug(3, "no-op %s for block %llu\n", - rw == READ ? "read" : "write", + rw == REQ_OP_READ ? "read" : "write", bh->b_blocknr); } } @@ -220,7 +220,7 @@ static void mark_buffer_clean(struct buffer_head *bh) void brelse(struct buffer_head *bh) { if (bh->b_dirty) - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); jfs_debug(3, "freeing block %llu/%p (total %d)\n", bh->b_blocknr, (void *) bh, --bh_count); ext2fs_free_mem(&bh); @@ -239,7 +239,7 @@ void mark_buffer_uptodate(struct buffer_head *bh, int val) void wait_on_buffer(struct buffer_head *bh) { if (!bh->b_uptodate) - ll_rw_block(READ, 1, &bh); + ll_rw_block(REQ_OP_READ, 0, 1, &bh); } @@ -443,7 +443,7 @@ try_backup_journal: retval = EXT2_ET_NO_MEMORY; goto errout; } - ll_rw_block(READ, 1, &bh); + ll_rw_block(REQ_OP_READ, 0, 1, &bh); retval = bh->b_err; if (retval) { brelse(bh); @@ -554,7 +554,7 @@ static errcode_t ext2fs_journal_load(journal_t *journal) journal_superblock_t *jsb; struct buffer_head *jbh = journal->j_sb_buffer; - ll_rw_block(READ, 1, &jbh); + ll_rw_block(REQ_OP_READ, 0, 1, &jbh); if (jbh->b_err) return jbh->b_err; diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h index a1c6951..8faf9c0 100644 --- a/e2fsck/jfs_user.h +++ b/e2fsck/jfs_user.h @@ -183,7 +183,7 @@ _INLINE_ __u32 hash_64(__u64 val, unsigned int bits) int journal_bmap(journal_t *journal, blk64_t block, unsigned long long *phys); struct buffer_head *getblk(kdev_t ctx, blk64_t blocknr, int blocksize); int sync_blockdev(kdev_t kdev); -void ll_rw_block(int rw, int dummy, struct buffer_head *bh[]); +void ll_rw_block(int rw, int op_flags, int nr, struct buffer_head *bh[]); void mark_buffer_dirty(struct buffer_head *bh); void mark_buffer_uptodate(struct buffer_head *bh, int val); void brelse(struct buffer_head *bh); diff --git a/e2fsck/journal.c b/e2fsck/journal.c index e83f3a9..6e3c982 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -156,14 +156,14 @@ int sync_blockdev(kdev_t kdev) return io_channel_flush(io) ? -EIO : 0; } -void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) +void ll_rw_block(int rw, int op_flags, int nr, struct buffer_head *bhp[]) { errcode_t retval; struct buffer_head *bh; for (; nr > 0; --nr) { bh = *bhp++; - if (rw == READ && !bh->b_uptodate) { + if (rw == REQ_OP_READ && !bh->b_uptodate) { jfs_debug(3, "reading block %llu/%p\n", bh->b_blocknr, (void *) bh); retval = io_channel_read_blk64(bh->b_io, @@ -177,7 +177,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) continue; } bh->b_uptodate = 1; - } else if (rw == WRITE && bh->b_dirty) { + } else if (rw == REQ_OP_WRITE && bh->b_dirty) { jfs_debug(3, "writing block %llu/%p\n", bh->b_blocknr, (void *) bh); @@ -195,7 +195,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) bh->b_uptodate = 1; } else { jfs_debug(3, "no-op %s for block %llu\n", - rw == READ ? "read" : "write", + rw == REQ_OP_READ ? "read" : "write", bh->b_blocknr); } } @@ -214,7 +214,7 @@ static void mark_buffer_clean(struct buffer_head * bh) void brelse(struct buffer_head *bh) { if (bh->b_dirty) - ll_rw_block(WRITE, 1, &bh); + ll_rw_block(REQ_OP_WRITE, 0, 1, &bh); jfs_debug(3, "freeing block %llu/%p (total %d)\n", bh->b_blocknr, (void *) bh, --bh_count); ext2fs_free_mem(&bh); @@ -233,7 +233,7 @@ void mark_buffer_uptodate(struct buffer_head *bh, int val) void wait_on_buffer(struct buffer_head *bh) { if (!bh->b_uptodate) - ll_rw_block(READ, 1, &bh); + ll_rw_block(REQ_OP_READ, 0, 1, &bh); } @@ -452,7 +452,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) retval = EXT2_ET_NO_MEMORY; goto errout; } - ll_rw_block(READ, 1, &bh); + ll_rw_block(REQ_OP_READ, 0, 1, &bh); if ((retval = bh->b_err) != 0) { brelse(bh); goto errout; @@ -591,7 +591,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) clear_problem_context(&pctx); - ll_rw_block(READ, 1, &jbh); + ll_rw_block(REQ_OP_READ, 0, 1, &jbh); if (jbh->b_err) { com_err(ctx->device_name, jbh->b_err, "%s", _("reading journal superblock\n")); @@ -732,7 +732,7 @@ static void e2fsck_journal_reset_super(e2fsck_t ctx, journal_superblock_t *jsb, e2fsck_journal_sb_csum_set(journal, jsb); mark_buffer_dirty(journal->j_sb_buffer); - ll_rw_block(WRITE, 1, &journal->j_sb_buffer); + ll_rw_block(REQ_OP_WRITE, 0, 1, &journal->j_sb_buffer); } static errcode_t e2fsck_journal_fix_corrupt_super(e2fsck_t ctx, diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c index 6210249..a185f34 100644 --- a/e2fsck/recovery.c +++ b/e2fsck/recovery.c @@ -101,7 +101,7 @@ static int do_readahead(journal_t *journal, unsigned int start) if (!buffer_uptodate(bh) && !buffer_locked(bh)) { bufs[nbufs++] = bh; if (nbufs == MAXBUF) { - ll_rw_block(READ, nbufs, bufs); + ll_rw_block(REQ_OP_READ, 0, nbufs, bufs); journal_brelse_array(bufs, nbufs); nbufs = 0; } @@ -110,7 +110,7 @@ static int do_readahead(journal_t *journal, unsigned int start) } if (nbufs) - ll_rw_block(READ, nbufs, bufs); + ll_rw_block(REQ_OP_READ, 0, nbufs, bufs); err = 0; failed: diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index f1a3f96..f90f3d4 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -17,8 +17,8 @@ #define KERN_ERR "" #define KERN_DEBUG "" -#define READ 0 -#define WRITE 1 +#define REQ_OP_READ 0 +#define REQ_OP_WRITE 1 #define cpu_to_be32(n) htonl(n) #define be32_to_cpu(n) ntohl(n)