[Top] [All Lists]

[RFD] : Allowing xfs_fsr to defragment portions of a file

To: xfs@xxxxxxxxxxx
Subject: [RFD] : Allowing xfs_fsr to defragment portions of a file
From: Dhruvesh Rathore <adrscube@xxxxxxxxx>
Date: Sun, 15 Feb 2015 20:08:46 +0530
Cc: Dave Chinner <david@xxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=VPzwnR0XEedfN1rOxGyvqAS8RJBdEQwuj/LSEmj0oUM=; b=NrsCwF6pYPZQl9eLP9iXJKetYi4TNlPKFOMPE86ezYz7q9XD4z6qsVSYlHM1KSYXPL 5DusJ/mZW8eGeBL+532vQjd3HTT9HP4ZR+BTNwO+7L4xECNhiaiYCbrTGBWfBpXJsHsa nrZI/YbliEcuB/RfSlIR28DhExS9Jotw1qGqFsZX383KIlQro3SWYMfFeM/6JF6Uo+ex MV5iQxGFXw0uKUl2W/m2Gt1XKduAodE/o2GYpjSD2BbljwXMOKv9JJcZtJ9YD5a7hvNr wM8MEnXM8I3Kn/nBgRgN0GijRUNOaUQ9XTL3XwwM6KtZosKwkM0UDI0hya6lKXuV09xw adqQ==

The xfs_fsr utility in its current state does not support defragmentation of
parts of file. Either the entire file is defragmented, or if free space is not
available then the operation is not performed.
We would like to enhance the utility allowing it to defragment parts
of the file, ins such a condition.

Our initial task was to understand how xfs_fsr currently defragments the file:

1) In /fsr/xfs_fsr.c from main() the control is passed to fsrfile().
In fsrfile(), we
open the original file and collect bstat information. A call is then made to

2) In fsrfile_common() we check if sufficient free space is available to
defragment the file, and if not then we exit. If free space is available, then a
call is made to packfile()

3) In packfile(), read_fd_bmap() function provides us with the current number of
extents used by the file (cur_nextents) and the ideal number of extents needed
to save the file (nextents). In function read_fd_bmap() the the
outmap[ ] structure
is also populated.

4) packfile() will initially allocate new extents (nextents) to the
temporary file and
then copy(swap) extents form the existing file. We then fchown() the new temp
file and space occupied by the prev fragmented copy is then freed.


Our understanding to the approach of defragmenting portions of a file
is as follows:

1) In fsrfile_common(), a new function will be called when the code
determines that
there is insufficient free space to defragment the entire file.

2) The new function performs the following tasks:

---> Call read_fd_bmap() to get cur_nextents and nextents(ideal). Using
nextents we will
then have to determine how many extents can be defragmented against
the free space

---> Creating a temp file will not be feasible as it will create a
problem when we want to
change owners.

---> The function will have to hence focus on swapping the existing
extents from the
fragmented file. For this a swap_extent() function will be needed,
which will take arguments
as the current extent and the location(in free space) where it needs
to be swapped to.

For the above functionality Dave suggested that we have a look at
and its usage.

We are however unsure of how to compress the extents which have been chosen for
defragmentation and keep the other extents untouched. We are also in
doubt about how to
proceed without creating a temp file for defragmentation.

Any thoughts, comments, opinions etc, are welcome
Thank you.


<Prev in Thread] Current Thread [Next in Thread>