Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* -*- mode: c; c-basic-offset: 8; -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * vim: noexpandtab sw=8 ts=8 sts=0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * io.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Buffer cache handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/bio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <cluster/masklog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "ocfs2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "alloc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "journal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "uptodate.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "buffer_head_io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "ocfs2_trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * Bits on bh->b_state used by ocfs2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * These MUST be after the JBD2 bits.  Hence, we use BH_JBDPrivateStart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) enum ocfs2_state_bits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	BH_NeedsValidate = BH_JBDPrivateStart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /* Expand the magic b_state functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) BUFFER_FNS(NeedsValidate, needs_validate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		      struct ocfs2_caching_info *ci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	trace_ocfs2_write_block((unsigned long long)bh->b_blocknr, ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	BUG_ON(buffer_jbd(bh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	/* No need to check for a soft readonly file system here. non
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 * journalled writes are only ever done on system files which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 * can get modified during recovery even if read-only. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (ocfs2_is_hard_readonly(osb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		ret = -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		mlog_errno(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	ocfs2_metadata_cache_io_lock(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	lock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* remove from dirty list before I/O. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	clear_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	get_bh(bh); /* for end_buffer_write_sync() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	bh->b_end_io = end_buffer_write_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	submit_bh(REQ_OP_WRITE, 0, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		ocfs2_set_buffer_uptodate(ci, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		/* We don't need to remove the clustered uptodate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		 * information for this bh as it's not marked locally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		 * uptodate. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		mlog_errno(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	ocfs2_metadata_cache_io_unlock(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) /* Caller must provide a bhs[] with all NULL or non-NULL entries, so it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * will be easier to handle read failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			   unsigned int nr, struct buffer_head *bhs[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	int new_bh = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	trace_ocfs2_read_blocks_sync((unsigned long long)block, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (!nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	/* Don't put buffer head and re-assign it to NULL if it is allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	 * outside since the caller can't be aware of this alternation!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	new_bh = (bhs[0] == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	for (i = 0 ; i < nr ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		if (bhs[i] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			bhs[i] = sb_getblk(osb->sb, block++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			if (bhs[i] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 				mlog_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		bh = bhs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		if (buffer_jbd(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			trace_ocfs2_read_blocks_sync_jbd(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 					(unsigned long long)bh->b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		if (buffer_dirty(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			/* This should probably be a BUG, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			 * at least return an error. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			mlog(ML_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			     "trying to sync read a dirty "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			     "buffer! (blocknr = %llu), skipping\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			     (unsigned long long)bh->b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		lock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		if (buffer_jbd(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #ifdef CATCH_BH_JBD_RACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			mlog(ML_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			     "block %llu had the JBD bit set "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			     "while I was in lock_buffer!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			     (unsigned long long)bh->b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			unlock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		get_bh(bh); /* for end_buffer_read_sync() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		bh->b_end_io = end_buffer_read_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		submit_bh(REQ_OP_READ, 0, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) read_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	for (i = nr; i > 0; i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		bh = bhs[i - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		if (unlikely(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			if (new_bh && bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				/* If middle bh fails, let previous bh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				 * finish its read and then put it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				 * aovoid bh leak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				if (!buffer_jbd(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 					wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 				put_bh(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 				bhs[i - 1] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			} else if (bh && buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 				clear_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		/* No need to wait on the buffer if it's managed by JBD. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if (!buffer_jbd(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		if (!buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			/* Status won't be cleared from here on out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			 * so we can safely record this and loop back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			 * to cleanup the other buffers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			goto read_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /* Caller must provide a bhs[] with all NULL or non-NULL entries, so it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * will be easier to handle read failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		      struct buffer_head *bhs[], int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		      int (*validate)(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				      struct buffer_head *bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int i, ignore_cache = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int new_bh = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	trace_ocfs2_read_blocks_begin(ci, (unsigned long long)block, nr, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	BUG_ON(!ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	BUG_ON((flags & OCFS2_BH_READAHEAD) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	       (flags & OCFS2_BH_IGNORE_CACHE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	if (bhs == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		mlog_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (nr < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		mlog(ML_ERROR, "asked to read %d blocks!\n", nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		mlog_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (nr == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	/* Don't put buffer head and re-assign it to NULL if it is allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 * outside since the caller can't be aware of this alternation!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	new_bh = (bhs[0] == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	ocfs2_metadata_cache_io_lock(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	for (i = 0 ; i < nr ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		if (bhs[i] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			bhs[i] = sb_getblk(sb, block++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			if (bhs[i] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				ocfs2_metadata_cache_io_unlock(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 				status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 				mlog_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				/* Don't forget to put previous bh! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		bh = bhs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		ignore_cache = (flags & OCFS2_BH_IGNORE_CACHE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		/* There are three read-ahead cases here which we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		 * be concerned with. All three assume a buffer has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		 * previously been submitted with OCFS2_BH_READAHEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		 * and it hasn't yet completed I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		 * 1) The current request is sync to disk. This rarely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		 *    happens these days, and never when performance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		 *    matters - the code can just wait on the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		 *    lock and re-submit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		 * 2) The current request is cached, but not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		 *    readahead. ocfs2_buffer_uptodate() will return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		 *    false anyway, so we'll wind up waiting on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		 *    buffer lock to do I/O. We re-check the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		 *    with after getting the lock to avoid a re-submit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		 * 3) The current request is readahead (and so must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		 *    also be a caching one). We short circuit if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		 *    buffer is locked (under I/O) and if it's in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		 *    uptodate cache. The re-check from #2 catches the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		 *    case that the previous read-ahead completes just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		 *    before our is-it-in-flight check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		if (!ignore_cache && !ocfs2_buffer_uptodate(ci, bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			trace_ocfs2_read_blocks_from_disk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			     (unsigned long long)bh->b_blocknr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			     (unsigned long long)ocfs2_metadata_cache_owner(ci));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			/* We're using ignore_cache here to say
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			 * "go to disk" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			ignore_cache = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		trace_ocfs2_read_blocks_bh((unsigned long long)bh->b_blocknr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			ignore_cache, buffer_jbd(bh), buffer_dirty(bh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		if (buffer_jbd(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		if (ignore_cache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			if (buffer_dirty(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				/* This should probably be a BUG, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				 * at least return an error. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			/* A read-ahead request was made - if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			 * buffer is already under read-ahead from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			 * previously submitted request than we are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			 * done here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			if ((flags & OCFS2_BH_READAHEAD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			    && ocfs2_buffer_read_ahead(ci, bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			lock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			if (buffer_jbd(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #ifdef CATCH_BH_JBD_RACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 				mlog(ML_ERROR, "block %llu had the JBD bit set "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 					       "while I was in lock_buffer!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 				     (unsigned long long)bh->b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 				BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 				unlock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			/* Re-check ocfs2_buffer_uptodate() as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			 * previously read-ahead buffer may have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			 * completed I/O while we were waiting for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			 * buffer lock. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 			if (!(flags & OCFS2_BH_IGNORE_CACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 			    && !(flags & OCFS2_BH_READAHEAD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 			    && ocfs2_buffer_uptodate(ci, bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 				unlock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 			get_bh(bh); /* for end_buffer_read_sync() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 			if (validate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 				set_buffer_needs_validate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			bh->b_end_io = end_buffer_read_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 			submit_bh(REQ_OP_READ, 0, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) read_failure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	for (i = (nr - 1); i >= 0; i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		bh = bhs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		if (!(flags & OCFS2_BH_READAHEAD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 			if (unlikely(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 				/* Clear the buffers on error including those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 				 * ever succeeded in reading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 				if (new_bh && bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 					/* If middle bh fails, let previous bh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 					 * finish its read and then put it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 					 * aovoid bh leak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 					if (!buffer_jbd(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 						wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 					put_bh(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 					bhs[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				} else if (bh && buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 					clear_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 			/* We know this can't have changed as we hold the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			 * owner sem. Avoid doing any work on the bh if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 			 * journal has it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 			if (!buffer_jbd(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			if (!buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				/* Status won't be cleared from here on out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 				 * so we can safely record this and loop back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 				 * to cleanup the other buffers. Don't need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 				 * remove the clustered uptodate information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				 * for this bh as it's not marked locally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				 * uptodate. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 				status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 				clear_buffer_needs_validate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 				goto read_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			if (buffer_needs_validate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 				/* We never set NeedsValidate if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 				 * buffer was held by the journal, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 				 * that better not have changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 				BUG_ON(buffer_jbd(bh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 				clear_buffer_needs_validate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 				status = validate(sb, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 				if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 					goto read_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		/* Always set the buffer in the cache, even if it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		 * a forced read, or read-ahead which hasn't yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		 * completed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		ocfs2_set_buffer_uptodate(ci, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	ocfs2_metadata_cache_io_unlock(ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	trace_ocfs2_read_blocks_end((unsigned long long)block, nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 				    flags, ignore_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /* Check whether the blkno is the super block or one of the backups. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) static void ocfs2_check_super_or_backup(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 					sector_t blkno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	u64 backup_blkno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (blkno == OCFS2_SUPER_BLOCK_BLKNO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		backup_blkno = ocfs2_backup_super_blkno(sb, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		if (backup_blkno == blkno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  * Write super block and backups doesn't need to collaborate with journal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  * so we don't need to lock ip_io_mutex and ci doesn't need to bea passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  * into this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 				struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	BUG_ON(buffer_jbd(bh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	ocfs2_check_super_or_backup(osb->sb, bh->b_blocknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		ret = -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		mlog_errno(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	lock_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	/* remove from dirty list before I/O. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	clear_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	get_bh(bh); /* for end_buffer_write_sync() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	bh->b_end_io = end_buffer_write_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &di->i_check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	submit_bh(REQ_OP_WRITE, 0, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	wait_on_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	if (!buffer_uptodate(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		mlog_errno(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }