[Ocfs2-tools-devel] [PATCH 03/12] libocfs2: Support directory block trailers.
Joel Becker
Joel.Becker at oracle.com
Wed Jan 7 23:27:07 PST 2009
On Wed, Jan 07, 2009 at 07:07:50PM -0800, Sunil Mushran wrote:
> I have one qs. Else looks good.
>
>> @@ -122,50 +124,57 @@ errcode_t ocfs2_link(ocfs2_filesys *fs, uint64_t dir, const char *name,
>> (ino > fs->fs_blocks))
>> return OCFS2_ET_INVALID_ARGUMENT;
>> + retval = ocfs2_malloc_block(fs->fs_io, &buf);
>> + if (retval)
>> + return retval;
>> +
>> + retval = ocfs2_read_inode(fs, dir, buf);
>> + if (retval)
>> + goto out_free;
>> +
>> + di = (struct ocfs2_dinode *)buf;
>> +
>> ls.name = name;
>> ls.namelen = name ? strlen(name) : 0;
>> ls.inode = ino;
>> ls.flags = flags;
>> ls.done = 0;
>> ls.sb = fs->fs_super;
>> + if (ocfs2_dir_has_trailer(fs, di))
>> + ls.blockend = ocfs2_dir_trailer_blk_off(fs);
>> + else
>> + ls.blockend = fs->fs_blocksize;
>> retval = ocfs2_dir_iterate(fs, dir,
>> OCFS2_DIRENT_FLAG_INCLUDE_EMPTY,
>> NULL, link_proc, &ls);
>> if (retval)
>> - return retval;
>> + goto out_free;
>> if (!ls.done) {
>> retval = ocfs2_expand_dir(fs, dir);
>> if (retval)
>> - return retval;
>> + goto out_free;
>> +
>> + /* Gotta refresh */
>> + retval = ocfs2_read_inode(fs, dir, buf);
>> + if (retval)
>> + goto out_free;
>>
>
> Unclear as to why we have to read the inode.
ocfs2_expand_dir() may allocate, modifying i_size and i_list,
but the buffer still has the old data.
Joel
--
"There is no more evil thing on earth than race prejudice, none at
all. I write deliberately -- it is the worst single thing in life
now. It justifies and holds together more baseness, cruelty and
abomination than any other sort of error in the world."
- H. G. Wells
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