* how to understand allocsp
@ 2006-08-24 20:11 Ming Zhang
2006-08-24 20:53 ` Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: Ming Zhang @ 2006-08-24 20:11 UTC (permalink / raw)
To: linux-xfs
Hi All
Play with xfs_io and feel confused about this allocsp.
Starting with a empty file.
xfs_io> bmap
/t/x: no extents
I assumed this will allocate space from 0 with 1048576 bytes. but seems
this is wrong.
xfs_io> allocsp 0 1048576
xfs_io> bmap
/t/x: no extents
Do this from a non-zero start, found file filled with 0.
xfs_io> allocsp 1048576 0
xfs_io> bmap
/t/x:
0: [0..2047]: 2147745792..2147747839
XFS_IOC_ALLOCSP64
Alter storage space associated with a section of the ordinary file
specified. The section
~~~~no idea what this "alter" mean here.
is specified by a variable of type xfs_flock64_t, pointed to by the
final argument. The data type xfs_flock64_t contains the following
members: l_whence is 0, 1, or 2 to indicate that the relative offset
l_start will be measured from the start of the file, the current
position, or the end of the file, respectively. l_start is the offset
from the position specified in l_whence. l_len is the size of the
section. An l_len value of zero frees up to the end of the file; in this
case, the end of file (i.e., file size) is set to the beginning of the
section freed. Any data previously written into this section is no
longer accessible. If the section specified is beyond the current end of
file, the file is grown and filled with zeroes. The l_len field is
currently ignored, and should be set to zero.
this "currently ignored" is ONLY when "section is beyond the current end
of file" or for any l_start?
Thanks!
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to understand allocsp
2006-08-24 20:11 how to understand allocsp Ming Zhang
@ 2006-08-24 20:53 ` Eric Sandeen
2006-08-24 21:01 ` Ming Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2006-08-24 20:53 UTC (permalink / raw)
To: mingz; +Cc: linux-xfs
Ming Zhang wrote:
> Hi All
>
> Play with xfs_io and feel confused about this allocsp.
>
> Starting with a empty file.
>
I honestly never keep this all straight without going back to the code,
but I'd start by looking at the comments for, and code in,
xfs_change_file_space and xfs_alloc_file_space.
/*
* XFS_IOC_RESVSP and XFS_IOC_UNRESVSP will reserve or unreserve
* file space.
* These calls do NOT zero the data space allocated to the file,
* nor do they change the file size.
*
* XFS_IOC_ALLOCSP and XFS_IOC_FREESP will allocate and free file
* space.
* These calls cause the new file data to be zeroed and the file
* size to be changed.
*/
The semantics of all this could be clearer, IMHO.
-Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to understand allocsp
2006-08-24 20:53 ` Eric Sandeen
@ 2006-08-24 21:01 ` Ming Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Ming Zhang @ 2006-08-24 21:01 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
see the code for this XFS_IOC_ALLOCSP
if (startoffset > fsize) {
error = xfs_alloc_file_space(ip, fsize,
startoffset - fsize, 0,
attr_flags);
if (error)
break;
}
va.va_mask = XFS_AT_SIZE;
va.va_size = startoffset;
error = xfs_setattr(bdp, &va, attr_flags, credp);
if (error)
return error;
clrprealloc = 1;
break;
so if offset is larger than current file size, it will allocate the
space and fill with zero. this is exactly what i met with "allocsp
1048576 0".
i would say this this pretty misleading. since "allocsp 0 1048576" can
be easily thought as "allocate 1048576 space start from 0" but now seems
only an ATTR is set.
Ming
On Thu, 2006-08-24 at 15:53 -0500, Eric Sandeen wrote:
> Ming Zhang wrote:
> > Hi All
> >
> > Play with xfs_io and feel confused about this allocsp.
> >
> > Starting with a empty file.
> >
>
> I honestly never keep this all straight without going back to the code,
> but I'd start by looking at the comments for, and code in,
> xfs_change_file_space and xfs_alloc_file_space.
>
> /*
> * XFS_IOC_RESVSP and XFS_IOC_UNRESVSP will reserve or unreserve
> * file space.
> * These calls do NOT zero the data space allocated to the file,
> * nor do they change the file size.
> *
> * XFS_IOC_ALLOCSP and XFS_IOC_FREESP will allocate and free file
> * space.
> * These calls cause the new file data to be zeroed and the file
> * size to be changed.
> */
>
> The semantics of all this could be clearer, IMHO.
>
> -Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-24 21:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-24 20:11 how to understand allocsp Ming Zhang
2006-08-24 20:53 ` Eric Sandeen
2006-08-24 21:01 ` Ming Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox