[Ocfs2-tools-devel] [PATCH 05/10] libocfs2: read/write now know inline data.
Joel Becker
Joel.Becker at oracle.com
Mon Jul 14 17:17:11 PDT 2008
On Fri, Jul 11, 2008 at 02:20:58PM +0800, Tao Ma wrote:
> +static errcode_t ocfs2_convert_inline_data_to_extents(ocfs2_cached_inode *ci)
> +{
> + errcode_t ret;
> + uint32_t bytes;
> + char *inline_data = NULL;
> + struct ocfs2_dinode *di = ci->ci_inode;
> + ocfs2_filesys *fs = ci->ci_fs;
> +
> + if (di->i_size) {
> + ret = ocfs2_malloc_block(fs->fs_io, &inline_data);
> + if (ret)
> + goto out;
> +
> + ret = ocfs2_inline_data_read(di, inline_data,
> + fs->fs_blocksize,
> + 0, &bytes);
> + if (ret)
> + goto out;
> +
> + ocfs2_dinode_new_extent_list(fs, di);
> + di->i_dyn_features &= ~OCFS2_INLINE_DATA_FL;
> + ret = ocfs2_write_cached_inode(fs, ci);
> + if (ret)
> + goto out;
> +
> + ret = ocfs2_file_block_write(ci, inline_data,
> + fs->fs_blocksize,
> + 0, &bytes);
> + if (ret)
> + goto out;
> + }
> +
> +out:
> + if (inline_data)
> + ocfs2_free(&inline_data);
> + return ret;
> +}
Actually, Tao, can we do this differently? While it's pretty
creative to use file_block_write to add the extents, it has the same
problem as the directory code. It wipes the data, writes out the inode,
then tries to add the extents - a crash is a problem, and so is ENOSPC
in this case.
Can you instead write ocfs2_cached_inode_insert_extent() to make
the extent insertion safe? Then write a public function
ocfs2_inline_data_to_extents() that allocates the extent, writes the
data to the extent, and uses ocfs2_cached_inode_insert_extent() to
insert it? This makes it safe (ocfs2_write_cached_inode() is the last
step). At the bottom of ocfs2_inline_data_to_extents() can check
S_ISDIR() and fixup the dirent. Plus, we can use that for tunefs
--fsfeatures noinline.
Joel
--
Brain: I shall pollute the water supply with this DNAdefibuliser,
turning everyone into mindless slaves.
Pinky: What about the people who drink bottled water?
Brain: Pinky, people who pay 5 dollars for a bottle of water are
already mindless slaves.
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list