Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup submit bh patchv4 #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include "internal.h"

static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
struct writeback_control *wbc);
static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
struct writeback_control *wbc);

#define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers)

Expand Down Expand Up @@ -2673,8 +2673,8 @@ static void end_bio_bh_io_sync(struct bio *bio)
bio_put(bio);
}

static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
struct writeback_control *wbc)
static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
struct writeback_control *wbc)
{
const enum req_op op = opf & REQ_OP_MASK;
struct bio *bio;
Expand Down Expand Up @@ -2717,12 +2717,11 @@ static int submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
}

submit_bio(bio);
return 0;
}

int submit_bh(blk_opf_t opf, struct buffer_head *bh)
void submit_bh(blk_opf_t opf, struct buffer_head *bh)
{
return submit_bh_wbc(opf, bh, NULL);
submit_bh_wbc(opf, bh, NULL);
}
EXPORT_SYMBOL(submit_bh);

Expand Down Expand Up @@ -2801,8 +2800,6 @@ EXPORT_SYMBOL(write_dirty_buffer);
*/
int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)
{
int ret = 0;

WARN_ON(atomic_read(&bh->b_count) < 1);
lock_buffer(bh);
if (test_clear_buffer_dirty(bh)) {
Expand All @@ -2817,14 +2814,14 @@ int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags)

get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(REQ_OP_WRITE | op_flags, bh);
submit_bh(REQ_OP_WRITE | op_flags, bh);
wait_on_buffer(bh);
if (!ret && !buffer_uptodate(bh))
ret = -EIO;
if (!buffer_uptodate(bh))
return -EIO;
} else {
unlock_buffer(bh);
}
return ret;
return 0;
}
EXPORT_SYMBOL(__sync_dirty_buffer);

Expand Down
10 changes: 4 additions & 6 deletions fs/jbd2/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ static int journal_submit_commit_record(journal_t *journal,
{
struct commit_header *tmp;
struct buffer_head *bh;
int ret;
struct timespec64 now;
blk_opf_t write_flags = REQ_OP_WRITE | REQ_SYNC;

*cbh = NULL;

Expand Down Expand Up @@ -155,13 +155,11 @@ static int journal_submit_commit_record(journal_t *journal,

if (journal->j_flags & JBD2_BARRIER &&
!jbd2_has_feature_async_commit(journal))
ret = submit_bh(REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH |
REQ_FUA, bh);
else
ret = submit_bh(REQ_OP_WRITE | REQ_SYNC, bh);
write_flags |= REQ_PREFLUSH | REQ_FUA;

submit_bh(write_flags, bh);
*cbh = bh;
return ret;
return 0;
}

/*
Expand Down
9 changes: 4 additions & 5 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
{
struct buffer_head *bh = journal->j_sb_buffer;
journal_superblock_t *sb = journal->j_superblock;
int ret;
int ret = 0;

/* Buffer got discarded which means block device got invalidated */
if (!buffer_mapped(bh)) {
Expand Down Expand Up @@ -1636,17 +1636,16 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
sb->s_checksum = jbd2_superblock_csum(journal, sb);
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(REQ_OP_WRITE | write_flags, bh);
submit_bh(REQ_OP_WRITE | write_flags, bh);
wait_on_buffer(bh);
if (buffer_write_io_error(bh)) {
clear_buffer_write_io_error(bh);
set_buffer_uptodate(bh);
ret = -EIO;
}
if (ret) {
printk(KERN_ERR "JBD2: Error %d detected when updating "
"journal superblock for %s.\n", ret,
journal->j_devname);
printk(KERN_ERR "JBD2: I/O error when updating journal superblock for %s.\n",
journal->j_devname);
if (!is_journal_aborted(journal))
jbd2_journal_abort(journal, ret);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ntfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,12 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping,
goto out;
}

static inline int ntfs_submit_bh_for_read(struct buffer_head *bh)
static inline void ntfs_submit_bh_for_read(struct buffer_head *bh)
{
lock_buffer(bh);
get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
return submit_bh(REQ_OP_READ, bh);
submit_bh(REQ_OP_READ, bh);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/linux/buffer_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void ll_rw_block(blk_opf_t, int, struct buffer_head * bh[]);
int sync_dirty_buffer(struct buffer_head *bh);
int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags);
void write_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags);
int submit_bh(blk_opf_t, struct buffer_head *);
void submit_bh(blk_opf_t, struct buffer_head *);
void write_boundary_block(struct block_device *bdev,
sector_t bblock, unsigned blocksize);
int bh_uptodate_or_lock(struct buffer_head *bh);
Expand Down