[Ocfs2-commits] mfasheh commits r2600 - trunk/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Sep 20 15:23:39 CDT 2005
Author: mfasheh
Signed-off-by: zab
Date: 2005-09-20 15:23:38 -0500 (Tue, 20 Sep 2005)
New Revision: 2600
Modified:
trunk/fs/ocfs2/buffer_head_io.c
trunk/fs/ocfs2/buffer_head_io.h
Log:
* commit a patch by Christoph Hellwig <hch at lst.de>:
we only need ocfs2_write_block because there's never more than one
buffer written.
Also remove lots of useless checks and replace the useful ones with
BUG_ON.
* Clean up the patch a little bit so it merges with our current tree and has
updated comments.
Signed-off-by: zab
Modified: trunk/fs/ocfs2/buffer_head_io.c
===================================================================
--- trunk/fs/ocfs2/buffer_head_io.c 2005-09-20 20:17:43 UTC (rev 2599)
+++ trunk/fs/ocfs2/buffer_head_io.c 2005-09-20 20:23:38 UTC (rev 2600)
@@ -39,97 +39,52 @@
#include "buffer_head_io.h"
-int ocfs2_write_blocks(ocfs2_super *osb, struct buffer_head *bhs[],
- int nr, struct inode *inode)
+int ocfs2_write_block(ocfs2_super *osb, struct buffer_head *bh,
+ struct inode *inode)
{
- int status = 0;
- int i;
- struct buffer_head *bh;
+ int ret = 0;
- mlog_entry("(bh[0]->b_blocknr = %llu, nr=%d, inode=%p)\n",
- (unsigned long long)bhs[0]->b_blocknr, nr, inode);
+ mlog_entry("(bh->b_blocknr = %llu, inode=%p)\n",
+ (unsigned long long)bh->b_blocknr, inode);
- if (osb == NULL || osb->sb == NULL || bhs == NULL) {
- status = -EINVAL;
- mlog_errno(status);
- goto bail;
- }
+ BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO);
+ BUG_ON(buffer_jbd(bh));
/* No need to check for a soft readonly file system here. non
* journalled writes are only ever done on system files which
* can get modified during recovery even if read-only. */
if (ocfs2_is_hard_readonly(osb)) {
- status = -EROFS;
- goto bail;
+ ret = -EROFS;
+ goto out;
}
- if (inode)
- down(&OCFS2_I(inode)->ip_io_sem);
- for (i = 0 ; i < nr ; i++) {
- bh = bhs[i];
- if (bh == NULL) {
- if (inode)
- up(&OCFS2_I(inode)->ip_io_sem);
- status = -EIO;
- mlog_errno(status);
- goto bail;
- }
+ down(&OCFS2_I(inode)->ip_io_sem);
- if (unlikely(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO)) {
- BUG();
- status = -EIO;
- mlog_errno(status);
- goto bail;
- }
+ lock_buffer(bh);
+ set_buffer_uptodate(bh);
- if (unlikely(buffer_jbd(bh))) {
- /* What are you thinking?! */
- mlog(ML_ERROR, "trying to write a jbd managed bh "
- "(blocknr = %llu), nr=%d\n",
- (unsigned long long)bh->b_blocknr, nr);
- BUG();
- }
+ /* remove from dirty list before I/O. */
+ clear_buffer_dirty(bh);
- lock_buffer(bh);
+ bh->b_end_io = end_buffer_write_sync;
+ submit_bh(WRITE, bh);
- set_buffer_uptodate(bh);
+ wait_on_buffer(bh);
- /* remove from dirty list before I/O. */
- clear_buffer_dirty(bh);
-
- get_bh(bh); /* for end_buffer_write_sync() */
- bh->b_end_io = end_buffer_write_sync;
- submit_bh(WRITE, bh);
+ if (buffer_uptodate(bh)) {
+ ocfs2_set_buffer_uptodate(inode, bh);
+ } else {
+ /* We don't need to remove the clustered uptodate
+ * information for this bh as it's not marked locally
+ * uptodate. */
+ ret = -EIO;
+ brelse(bh);
}
- for (i = (nr - 1) ; i >= 0; i--) {
- bh = bhs[i];
-
- wait_on_buffer(bh);
-
- if (!buffer_uptodate(bh)) {
- /* Status won't be cleared from here on out,
- * so we can safely record this and loop back
- * to cleanup the other buffers. Don't need to
- * remove the clustered uptodate information
- * for this bh as it's not marked locally
- * uptodate. */
- status = -EIO;
- brelse(bh);
- bhs[i] = NULL;
- continue;
- }
-
- if (inode)
- ocfs2_set_buffer_uptodate(inode, bh);
- }
- if (inode)
- up(&OCFS2_I(inode)->ip_io_sem);
-
-bail:
-
- mlog_exit(status);
- return status;
+ up(&OCFS2_I(inode)->ip_io_sem);
+out:
+ mlog_exit(ret);
+ return ret;
}
int ocfs2_read_blocks(ocfs2_super *osb, u64 block, int nr,
Modified: trunk/fs/ocfs2/buffer_head_io.h
===================================================================
--- trunk/fs/ocfs2/buffer_head_io.h 2005-09-20 20:17:43 UTC (rev 2599)
+++ trunk/fs/ocfs2/buffer_head_io.h 2005-09-20 20:23:38 UTC (rev 2600)
@@ -31,20 +31,15 @@
void ocfs2_end_buffer_io_sync(struct buffer_head *bh,
int uptodate);
-/* Yosh made me do it. */
-static inline int ocfs2_write_block(ocfs2_super *osb,
- struct buffer_head *bh,
- struct inode *inode);
static inline int ocfs2_read_block(ocfs2_super *osb,
u64 off,
struct buffer_head **bh,
int flags,
struct inode *inode);
-int ocfs2_write_blocks(ocfs2_super *osb,
- struct buffer_head *bh[],
- int nr,
- struct inode *inode);
+int ocfs2_write_block(ocfs2_super *osb,
+ struct buffer_head *bh,
+ struct inode *inode);
int ocfs2_read_blocks(ocfs2_super *osb,
u64 block,
int nr,
@@ -56,16 +51,6 @@
#define OCFS2_BH_CACHED 1
#define OCFS2_BH_READAHEAD 8 /* use this to pass READA down to submit_bh */
-static inline int ocfs2_write_block(ocfs2_super * osb, struct buffer_head *bh,
- struct inode *inode)
-{
- int status;
-
- status = ocfs2_write_blocks(osb, &bh, 1, inode);
-
- return status;
-}
-
static inline int ocfs2_read_block(ocfs2_super * osb, u64 off,
struct buffer_head **bh, int flags,
struct inode *inode)
More information about the Ocfs2-commits
mailing list