[Ocfs2-tools-devel] [PATCH 18/22] tunefs rework: Add feature_sparse_files.c
Tao Ma
tao.ma at oracle.com
Thu Jul 31 20:22:21 PDT 2008
Joel Becker wrote:
> Enable and disable the sparse file feature.
>
> This is the 'sparse' key to the tunefs option '--fs-features'.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
> +static errcode_t get_total_free_clusters(ocfs2_filesys *fs,
> + uint32_t *clusters)
This function and "empty_clusters" shows up in patch 17. So could you
please abstract them out to be non-static?
> +{
> + errcode_t ret;
> + uint64_t blkno;
> + char *buf = NULL;
> + struct ocfs2_dinode *di = NULL;
> +
> + ret = ocfs2_malloc_block(fs->fs_io, &buf);
> + if (ret)
> + goto bail;
> +
> + ret = ocfs2_lookup_system_inode(fs, GLOBAL_BITMAP_SYSTEM_INODE,
> + 0, &blkno);
> + if (ret)
> + goto bail;
> +
> + ret = ocfs2_read_inode(fs, blkno, buf);
> + if (ret)
> + goto bail;
> +
> + di = (struct ocfs2_dinode *)buf;
> + if (clusters)
> + *clusters = di->id1.bitmap1.i_total - di->id1.bitmap1.i_used;
> +bail:
> + if (buf)
> + ocfs2_free(&buf);
> + return ret;
> +}
> +
> +static int disable_sparse_files(ocfs2_filesys *fs, int flags)
> +{
> + errcode_t ret = 0;
> + struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
> + struct fill_hole_context ctxt;
> +
> + if (!ocfs2_sparse_alloc(super)) {
> + verbosef(VL_APP,
> + "Sparse file feature is not enabled; "
> + "nothing to disable\n");
> + goto out;
> + }
> +
> + if (ocfs2_writes_unwritten_extents(super)) {
> + errorf("Unwritten extents are enabled on device \"%s\"; "
> + "sparse files cannot be disabled\n",
> + fs->fs_devname);
> + ret = TUNEFS_ET_UNWRITTEN_PRESENT;
> + goto out;
> + }
I remembered that if the user want to remove "sparse", unwritten is
removed automatically by you now, right? So if we hit here, we may meet
with a bug in tunefs. So should we say something loudly other than this?
Regards,
Tao
More information about the Ocfs2-tools-devel
mailing list