diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2013-06-24 03:08:38 +0900 |
---|---|---|
committer | Daniel Phillips <daniel@tux3.org> | 2013-06-24 03:08:38 +0900 |
commit | 17377f58d0c8073debc8fe8f5484702d47bce096 (patch) | |
tree | 85cc991c792e044051745b523e39bb60b39ad660 | |
parent | ba3049d6f635255ef35dbe5b7d4325597f7db5f5 (diff) | |
download | linux-tux3-17377f58d0c8073debc8fe8f5484702d47bce096.tar.gz |
tux3: Allow to use other variants of WRITE command
There are some variant of WRITE, e.g., WRITE_SYNC, WRITE_FLUSH, etc.
To support those, this tweaks write path.
- Rename enum in tux3.c. READ and WRITE are conflicting with commands.
- Now WRITE is bit mask. So this converts the following
"rw == READ" => "!(rw & WRITE)"
"rw == WRITE" => "(rw & WRITE)"
With this change, we can specify e.g. WRITE_SYNC for fsync().
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
-rw-r--r-- | fs/tux3/buffer_writeback.c | 26 | ||||
-rw-r--r-- | fs/tux3/filemap.c | 14 | ||||
-rw-r--r-- | fs/tux3/log.c | 2 |
3 files changed, 21 insertions, 21 deletions
diff --git a/fs/tux3/buffer_writeback.c b/fs/tux3/buffer_writeback.c index 33c27fd538189f..6ee25b04278bd7 100644 --- a/fs/tux3/buffer_writeback.c +++ b/fs/tux3/buffer_writeback.c @@ -140,7 +140,7 @@ static struct bio *bufvec_bio_alloc(struct sb *sb, unsigned int count, return bio; } -static void bufvec_submit_bio(struct bufvec *bufvec) +static void bufvec_submit_bio(int rw, struct bufvec *bufvec) { struct sb *sb = tux_sb(bufvec_inode(bufvec)->i_sb); struct bio *bio = bufvec->bio; @@ -153,7 +153,7 @@ static void bufvec_submit_bio(struct bufvec *bufvec) bio->bi_size >> sb->blockbits); iowait_inflight_inc(sb->iowait); - submit_bio(WRITE, bio); + submit_bio(rw, bio); } /* @@ -362,7 +362,7 @@ still_busy: * FIXME: Some buffers on the page can be contiguous, we can submit * those as one bio if contiguous. */ -static void bufvec_bio_add_multiple(struct bufvec *bufvec) +static void bufvec_bio_add_multiple(int rw, struct bufvec *bufvec) { /* FIXME: inode is still guaranteed to be available? */ struct sb *sb = tux_sb(bufvec_inode(bufvec)->i_sb); @@ -371,7 +371,7 @@ static void bufvec_bio_add_multiple(struct bufvec *bufvec) /* If there is bio, submit it */ if (bufvec->bio) - bufvec_submit_bio(bufvec); + bufvec_submit_bio(rw, bufvec); page = bufvec->on_page[0].buffer->b_page; @@ -406,7 +406,7 @@ static void bufvec_bio_add_multiple(struct bufvec *bufvec) bufvec_bio_add_buffer(bufvec, buffer); - bufvec_submit_bio(bufvec); + bufvec_submit_bio(rw, bufvec); } bufvec_prepare_and_unlock_page(page); @@ -458,7 +458,7 @@ static void bufvec_end_io(struct bio *bio, int err) * FIXME: We can free buffers early, and avoid to use buffers in I/O * completion, after prepared the page (like __mpage_writepage). */ -static void bufvec_bio_add_page(struct bufvec *bufvec) +static void bufvec_bio_add_page(int rw, struct bufvec *bufvec) { /* FIXME: inode is still guaranteed to be available? */ struct sb *sb = tux_sb(bufvec_inode(bufvec)->i_sb); @@ -479,7 +479,7 @@ static void bufvec_bio_add_page(struct bufvec *bufvec) if (!bufvec->bio || !bio_add_page(bufvec->bio, page, length, offset)) { /* Couldn't add. So submit old bio and allocate new bio */ if (bufvec->bio) - bufvec_submit_bio(bufvec); + bufvec_submit_bio(rw, bufvec); bufvec->bio = bufvec_bio_alloc(sb, bufvec_contig_count(bufvec) + 1, @@ -554,7 +554,7 @@ int bufvec_io(int rw, struct bufvec *bufvec, block_t physical, unsigned count) bufvec_contig_index(bufvec), bufvec_contig_count(bufvec), physical, count); - assert(rw == WRITE); /* FIXME: now only support WRITE */ + assert(rw & WRITE); /* FIXME: now only support WRITE */ assert(bufvec_contig_count(bufvec) >= count); if (bufvec->on_page_idx) { @@ -568,7 +568,7 @@ int bufvec_io(int rw, struct bufvec *bufvec, block_t physical, unsigned count) * If new range is not contiguous with the pending bio, * submit the pending bio. */ - bufvec_submit_bio(bufvec); + bufvec_submit_bio(rw, bufvec); } /* Add buffers to bio for each page */ @@ -593,15 +593,15 @@ int bufvec_io(int rw, struct bufvec *bufvec, block_t physical, unsigned count) } if (multiple) - bufvec_bio_add_multiple(bufvec); + bufvec_bio_add_multiple(rw, bufvec); else - bufvec_bio_add_page(bufvec); + bufvec_bio_add_page(rw, bufvec); } } /* If no more buffer, submit the pending bio */ if (bufvec->bio && !bufvec_next_buffer_page(bufvec)) - bufvec_submit_bio(bufvec); + bufvec_submit_bio(rw, bufvec); return 0; } @@ -808,7 +808,7 @@ int tux3_volmap_io(int rw, struct bufvec *bufvec) unsigned count = bufvec_contig_count(bufvec); /* FIXME: For now, this is only for write */ - assert(rw == WRITE); + assert(rw & WRITE); return __tux3_volmap_io(rw, bufvec, physical, count); } diff --git a/fs/tux3/filemap.c b/fs/tux3/filemap.c index 5cb57b11cea5b0..e3bd04e4c81184 100644 --- a/fs/tux3/filemap.c +++ b/fs/tux3/filemap.c @@ -623,28 +623,28 @@ static int map_region(struct inode *inode, block_t start, unsigned count, return segs; } -static int filemap_extent_io(enum map_mode mode, struct bufvec *bufvec); +static int filemap_extent_io(enum map_mode mode, int rw, struct bufvec *bufvec); int tux3_filemap_overwrite_io(int rw, struct bufvec *bufvec) { - enum map_mode mode = (rw == READ) ? MAP_READ : MAP_WRITE; - return filemap_extent_io(mode, bufvec); + enum map_mode mode = (rw & WRITE) ? MAP_WRITE : MAP_READ; + return filemap_extent_io(mode, rw, bufvec); } int tux3_filemap_redirect_io(int rw, struct bufvec *bufvec) { - enum map_mode mode = (rw == READ) ? MAP_READ : MAP_REDIRECT; - return filemap_extent_io(mode, bufvec); + enum map_mode mode = (rw & WRITE) ? MAP_REDIRECT : MAP_READ; + return filemap_extent_io(mode, rw, bufvec); } #ifdef __KERNEL__ #include <linux/mpage.h> -static int filemap_extent_io(enum map_mode mode, struct bufvec *bufvec) +static int filemap_extent_io(enum map_mode mode, int rw, struct bufvec *bufvec) { struct inode *inode = bufvec_inode(bufvec); block_t block, index = bufvec_contig_index(bufvec); unsigned count = bufvec_contig_count(bufvec); - int err, rw = (mode == MAP_READ) ? READ : WRITE; + int err; struct block_segment seg[10]; /* FIXME: For now, this is only for write */ diff --git a/fs/tux3/log.c b/fs/tux3/log.c index 2793cecf048707..9f06f72b5734f7 100644 --- a/fs/tux3/log.c +++ b/fs/tux3/log.c @@ -166,7 +166,7 @@ int tux3_logmap_io(int rw, struct bufvec *bufvec) struct sb *sb = tux_sb(logmap->i_sb); unsigned count = bufvec_contig_count(bufvec); - assert(rw == WRITE); + assert(rw & WRITE); assert(bufvec_contig_index(bufvec) == 0); while (count > 0) { |