Cluster movement?

Is there any way to move small files? When I use DeviceIoControl with
FSCTL_MOVE_FILE on a small file, the function returnes success, but the
file isn’t moved!

Code:
firstFreeCluster = findFirstFreeCluster();
file = CreateFile(…);
MOVE_FILE_DATA move;
move.ClusterCount = 1;
move.FileHandle = file;
move.StartingVcn.QuadPart = 0;
move.StartingLcn.QuadPart = firstFreeCluster;
if( DeviceIoControl( disk, FSCTL_MOVE_FILE, &move, sizeof(MOVE_FILE_DATA),
NULL, 0, &q, NULL) == 0 ) {
bla…
}
else
bla…
-EndOfCode-

Is there any way to move one cluster at the time, because when I execute
this code, GetLastError() returned 5. It works if I set ClusterCount to eg.
4.

/Gregor Brunmar


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Gregor,

Are you doing this on NTFS? If so, the problem is that the data is stored
“in-line” within the MFT entry. Thus, you can’t move the data (you would
need to move the MFT, not the file data.)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

See the new NTFSD FAQ on the OSR Web Site!

-----Original Message-----
From: xxxxx@home.se [mailto:xxxxx@home.se]
Sent: Thursday, October 18, 2001 1:45 PM
To: File Systems Developers
Subject: [ntfsd] Cluster movement?

Is there any way to move small files? When I use DeviceIoControl with
FSCTL_MOVE_FILE on a small file, the function returnes success, but the
file isn’t moved!

Code:
firstFreeCluster = findFirstFreeCluster();
file = CreateFile(…);
MOVE_FILE_DATA move;
move.ClusterCount = 1;
move.FileHandle = file;
move.StartingVcn.QuadPart = 0;
move.StartingLcn.QuadPart = firstFreeCluster;
if( DeviceIoControl( disk, FSCTL_MOVE_FILE, &move, sizeof(MOVE_FILE_DATA),
NULL, 0, &q, NULL) == 0 ) {
bla…
}
else
bla…
-EndOfCode-

Is there any way to move one cluster at the time, because when I execute
this code, GetLastError() returned 5. It works if I set ClusterCount to eg.
4.

/Gregor Brunmar


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I have NTFS, but how come it works with large files when moving eg. 4 clusters
at the time? The MFT is unmovable on Win2K I’ve read, do I have to upgrade to
WinXP where it can be done? But it must be done, how else does defrag-programs
work?

/Gregor Brunmar

Tony Mason wrote:

Gregor,

Are you doing this on NTFS? If so, the problem is that the data is stored
“in-line” within the MFT entry. Thus, you can’t move the data (you would
need to move the MFT, not the file data.)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

See the new NTFSD FAQ on the OSR Web Site!

-----Original Message-----
From: xxxxx@home.se [mailto:xxxxx@home.se]
Sent: Thursday, October 18, 2001 1:45 PM
To: File Systems Developers
Subject: [ntfsd] Cluster movement?

Is there any way to move small files? When I use DeviceIoControl with
FSCTL_MOVE_FILE on a small file, the function returnes success, but the
file isn’t moved!

Code:
firstFreeCluster = findFirstFreeCluster();
file = CreateFile(…);
MOVE_FILE_DATA move;
move.ClusterCount = 1;
move.FileHandle = file;
move.StartingVcn.QuadPart = 0;
move.StartingLcn.QuadPart = firstFreeCluster;
if( DeviceIoControl( disk, FSCTL_MOVE_FILE, &move, sizeof(MOVE_FILE_DATA),
NULL, 0, &q, NULL) == 0 ) {
bla…
}
else
bla…
-EndOfCode-

Is there any way to move one cluster at the time, because when I execute
this code, GetLastError() returned 5. It works if I set ClusterCount to eg.
4.

/Gregor Brunmar


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@home.se
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Gregor,

Small files are stored in-line. Once they become large enough that they
cannot be stored in-line, they are assigned to separate storage areas in the
file system. At that point, they can then be moved.

To the best of my knowledge, moving to Windows XP is not going to change the
behavior for you in this regard.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Gregor Brunmar [mailto:xxxxx@home.se]
Sent: Thursday, October 18, 2001 6:22 PM
To: File Systems Developers
Subject: [ntfsd] RE: Cluster movement?

I have NTFS, but how come it works with large files when moving eg. 4
clusters
at the time? The MFT is unmovable on Win2K I’ve read, do I have to upgrade
to
WinXP where it can be done? But it must be done, how else does
defrag-programs
work?

/Gregor Brunmar

Tony Mason wrote:

Gregor,

Are you doing this on NTFS? If so, the problem is that the data is stored
“in-line” within the MFT entry. Thus, you can’t move the data (you would
need to move the MFT, not the file data.)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

See the new NTFSD FAQ on the OSR Web Site!

-----Original Message-----
From: xxxxx@home.se [mailto:xxxxx@home.se]
Sent: Thursday, October 18, 2001 1:45 PM
To: File Systems Developers
Subject: [ntfsd] Cluster movement?

Is there any way to move small files? When I use DeviceIoControl with
FSCTL_MOVE_FILE on a small file, the function returnes success, but the
file isn’t moved!

Code:
firstFreeCluster = findFirstFreeCluster();
file = CreateFile(…);
MOVE_FILE_DATA move;
move.ClusterCount = 1;
move.FileHandle = file;
move.StartingVcn.QuadPart = 0;
move.StartingLcn.QuadPart = firstFreeCluster;
if( DeviceIoControl( disk, FSCTL_MOVE_FILE, &move,
sizeof(MOVE_FILE_DATA),
NULL, 0, &q, NULL) == 0 ) {
bla…
}
else
bla…
-EndOfCode-

Is there any way to move one cluster at the time, because when I execute
this code, GetLastError() returned 5. It works if I set ClusterCount to
eg.
4.

/Gregor Brunmar


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@home.se
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

My question remains, how does defrag-programs move the small files?
Why does DeviceIoControl(FSCTL_MOVE_DATA) returnes success if the cluster isn’t
moved?
And why isn’t this in the MSDN?

/Gregor

Tony Mason wrote:

Gregor,

Small files are stored in-line. Once they become large enough that they
cannot be stored in-line, they are assigned to separate storage areas in the
file system. At that point, they can then be moved.

To the best of my knowledge, moving to Windows XP is not going to change the
behavior for you in this regard.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Gregor Brunmar [mailto:xxxxx@home.se]
Sent: Thursday, October 18, 2001 6:22 PM
To: File Systems Developers
Subject: [ntfsd] RE: Cluster movement?

I have NTFS, but how come it works with large files when moving eg. 4
clusters
at the time? The MFT is unmovable on Win2K I’ve read, do I have to upgrade
to
WinXP where it can be done? But it must be done, how else does
defrag-programs
work?

/Gregor Brunmar

Tony Mason wrote:

> Gregor,
>
> Are you doing this on NTFS? If so, the problem is that the data is stored
> “in-line” within the MFT entry. Thus, you can’t move the data (you would
> need to move the MFT, not the file data.)
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
> See the new NTFSD FAQ on the OSR Web Site!
>
> -----Original Message-----
> From: xxxxx@home.se [mailto:xxxxx@home.se]
> Sent: Thursday, October 18, 2001 1:45 PM
> To: File Systems Developers
> Subject: [ntfsd] Cluster movement?
>
> Is there any way to move small files? When I use DeviceIoControl with
> FSCTL_MOVE_FILE on a small file, the function returnes success, but the
> file isn’t moved!
>
> Code:
> firstFreeCluster = findFirstFreeCluster();
> file = CreateFile(…);
> MOVE_FILE_DATA move;
> move.ClusterCount = 1;
> move.FileHandle = file;
> move.StartingVcn.QuadPart = 0;
> move.StartingLcn.QuadPart = firstFreeCluster;
> if( DeviceIoControl( disk, FSCTL_MOVE_FILE, &move,
sizeof(MOVE_FILE_DATA),
> NULL, 0, &q, NULL) == 0 ) {
> bla…
> }
> else
> bla…
> -EndOfCode-
>
> Is there any way to move one cluster at the time, because when I execute
> this code, GetLastError() returned 5. It works if I set ClusterCount to
eg.
> 4.
>
> /Gregor Brunmar
>
> —
> You are currently subscribed to ntfsd as: xxxxx@osr.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntfsd as: xxxxx@home.se
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@home.se
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

----- Original Message -----
From: Gregor Brunmar
To: File Systems Developers
Sent: Friday, October 19, 2001 6:40 AM
Subject: [ntfsd] RE: Cluster movement?

> My question remains, how does defrag-programs move the small files?

As Tony tried to explain, files small enough to fit within their MFT entries
aren’t moved at all - period. It may be that if the MFT itself is extended
to obtain more space the MFT extension as a whole can be moved by a
defragmenter, but if so that won’t be seen during the operations on the
individual small files within it.

The only situation in which file entries would move within the MFT would
be if a defragmenter attempted to move existing entries into ‘holes’ earlier
in the MFT so that the MFT could be compressed by lopping off unused space
at its end. However, this would change the ‘reference’ identifiers of these
files, which might upset other software that assumes they will remain stable
for the life of the file (I’m not certain that Microsoft guarantees such
stability, but some other systems with similar mechanisms do).

> Why does DeviceIoControl(FSCTL_MOVE_DATA) returnes success if the cluster
isn’t
> moved?

Presumably so as not to confuse whatever software is using it in such cases:
the desired effect has been obtained without the necessity of data movement.

> And why isn’t this in the MSDN?

That you will have to ask Microsoft.

- bill

>
> /Gregor
>
> Tony Mason wrote:
>
> > Gregor,
> >
> > Small files are stored in-line. Once they become large enough that they
> > cannot be stored in-line, they are assigned to separate storage areas in
the
> > file system. At that point, they can then be moved.
> >
> > To the best of my knowledge, moving to Windows XP is not going to change
the
> > behavior for you in this regard.
> >
> > Regards,
> >
> > Tony
> >
> > Tony Mason
> > Consulting Partner
> > OSR Open Systems Resources, Inc.
> > http://www.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com