[Ocfs2-tools-devel] [PATCH 4/6] Fix filesize in create_file
Goldwyn Rodrigues
rgoldwyn at gmail.com
Tue Nov 8 20:07:58 PST 2011
On Wed, Oct 26, 2011 at 2:21 AM, Sunil Mushran <sunil.mushran at oracle.com> wrote:
> I am confused. create_file() merely creates a file and adds it
> to a directory. It dies not allocate any space to it. The file size
> should be zero.
Hmm, I lost my previous work. However, AFAIR create_file used to
create a file with size as zero and with exactly one extent. I am
unable to reproduce it now.
Using the latest ocfs2-tools, fswreck is failing much before this
(local,noinline-data):
goldwyn at shrek:~/repos/ocfs2-tools> sudo ./fswreck/fswreck -c
INODE_SIZE /dev/sda10
fswreck 1.8.0
fswreck: Directory entry not found (corrupt.c,42)
This needs more time and effort and I will check after I get back from
my vacation.
>
> On 08/22/2011 03:36 PM, Goldwyn Rodrigues wrote:
>>
>> While creating a new file, the filesize is left at zero, even though
>> there is an extent in the file.
>> This fix is required because further extents added using
>> ocfs2_extend_allocation compute the offset based on current filesize.
>>
>> Signed-off-by: Goldwyn Rodrigues<rgoldwyn at suse.de>
>> ---
>> fswreck/extent.c | 18 ++++++++++++++++++
>> 1 files changed, 18 insertions(+), 0 deletions(-)
>>
>> diff --git a/fswreck/extent.c b/fswreck/extent.c
>> index e36deb9..f6fade0 100644
>> --- a/fswreck/extent.c
>> +++ b/fswreck/extent.c
>> @@ -44,6 +44,12 @@ void create_file(ocfs2_filesys *fs, uint64_t blkno,
>> uint64_t *retblkno)
>> errcode_t ret;
>> uint64_t tmp_blkno = 0;
>> char random_name[OCFS2_MAX_FILENAME_LEN];
>> + char *buf;
>> + struct ocfs2_dinode *di;
>> +
>> + ret = ocfs2_malloc_block(fs->fs_io,&buf);
>> + if (ret)
>> + FSWRK_COM_FATAL(progname, errno);
>>
>> memset(random_name, 0, sizeof(random_name));
>> sprintf(random_name, "testXXXXXX");
>> @@ -70,8 +76,20 @@ void create_file(ocfs2_filesys *fs, uint64_t blkno,
>> uint64_t *retblkno)
>> if (ret)
>> FSWRK_COM_FATAL(progname, ret);
>>
>> + /* Fix the i_size of the new file to greater than zero */
>> + ret = ocfs2_read_inode(fs, tmp_blkno, buf);
>> + if (ret)
>> + FSWRK_COM_FATAL(progname, ret);
>> + di = (struct ocfs2_dinode *)buf;
>> +
>> + di->i_size = ocfs2_clusters_to_bytes(fs, 1) - 25;
>> + ret = ocfs2_write_inode(fs, tmp_blkno, buf);
>> + if (ret)
>> + FSWRK_COM_FATAL(progname, ret);
>> +
>> *retblkno = tmp_blkno;
>>
>> + ocfs2_free(&buf);
>> return;
>> }
>>
>
>
--
Goldwyn
More information about the Ocfs2-tools-devel
mailing list