* ext2: How do we make sure indirect blocks are writeback before data block?
@ 2020-11-19 16:42 bbw725
0 siblings, 0 replies; only message in thread
From: bbw725 @ 2020-11-19 16:42 UTC (permalink / raw)
To: linux-kernel
Hi all,
I have one question about how ext2 's indirect block being write back. (I know ext2 is out of date but I am just starting learning).
From ext2_alloc_branch(), after it got indirect block and then it will setup the 'chain', during this, it will mark buffer head of indirect blocks to dirty,
and then the inode's associated block dev will write back this dirty buffer head.
My question is these indirect blocks are meta data of this inode, and usually we should write back inode's data first and then its meta data, but here, after we mark buffer heads of indirect blocks and how do we make sure they will be written back before its data ?
ext2_alloc_branch (...)
{
bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
if (unlikely(!bh)) {
err = -ENOMEM;
goto failed;
}
branch[n].bh = bh;
lock_buffer(bh);
memset(bh->b_data, 0, blocksize);
branch[n].p = (__le32 *) bh->b_data + offsets[n];
branch[n].key = cpu_to_le32(new_blocks[n]);
*branch[n].p = branch[n].key;
if ( n == indirect_blks) {
current_block = new_blocks[n];
/*
* End of chain, update the last new metablock of
* the chain to point to the new allocated
* data blocks numbers
*/
for (i=1; i < num; i++)
*(branch[n].p + i) = cpu_to_le32(++current_block);
}
set_buffer_uptodate(bh);
unlock_buffer(bh);
mark_buffer_dirty_inode(bh, inode);
/* We used to sync bh here if IS_SYNC(inode).
* But we now rely upon generic_write_sync()
* and b_inode_buffers. But not for directories.
*/
Thanks very much.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-19 16:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 16:42 ext2: How do we make sure indirect blocks are writeback before data block? bbw725
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome