From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sankar P Subject: How defragmentation works in linux filesystems ? Date: Mon, 7 Jan 2013 14:57:59 +0530 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 To: Kernelnewbies@kernelnewbies.org, linux-fsdevel@vger.kernel.org Return-path: Received: from mail-ia0-f179.google.com ([209.85.210.179]:48302 "EHLO mail-ia0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796Ab3AGJ2A (ORCPT ); Mon, 7 Jan 2013 04:28:00 -0500 Received: by mail-ia0-f179.google.com with SMTP id o25so15941569iad.38 for ; Mon, 07 Jan 2013 01:27:59 -0800 (PST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, Is there any technical article explaining how defragmentation works in linux filesystems, say btrfs or ext4 ? Do they recreate the file data blocks and change the root pointer to the new extent ? Or do they do some kind of moving blocks around ? Or is it based on some other strategy ? Partial defragmentation (based on either byte offset or extents) is also supported by any of the file systems ? Is there a standard way to trigger a defragmentation operation (an ioctl ?) that my filesystem could implement so that any user space tool that work with other fs will work with mine too ? (Like, how FIEBMAP ioctl can help in giving the extent information for a file from the userspace) I googled a bit to find any articles explaining this. But could not get anything the design. So links to any documentation, article explaining the linux filesystems' way of defragmenting are welcome. Thanks. -- Sankar P http://psankar.blogspot.com