lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 20 Nov 2020 00:42:54 +0800 (CST)
From:   bbw725 <bbw725@....com>
To:     linux-kernel@...r.kernel.org
Subject: ext2: How do we make sure indirect blocks are writeback before data
 block?

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.

Powered by blists - more mailing lists