Commit 4f7e6737 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: fix misleading and incomplete comment of btrfs_truncate()

The comment at the top of btrfs_truncate() mentions that csum items are
dropped or truncated to the new i_size, but this is wrong and non sense,
as they are unrelated to the i_size and are located in the csums tree and
not on a tree with inode items (fs/subvolume tree or a log tree). Instead
that claim applies to file extent items, so fix the comment to refer to
them instead.

While at it make the whole comment for the function more descriptive and
follow the kernel doc style.
Tested-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 04587ad9
...@@ -4472,15 +4472,25 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -4472,15 +4472,25 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
#define NEED_TRUNCATE_BLOCK 1 #define NEED_TRUNCATE_BLOCK 1
/* /*
* this can truncate away extent items, csum items and directory items. * Remove inode items from a given root.
* It starts at a high offset and removes keys until it can't find
* any higher than new_size
* *
* csum items that cross the new i_size are truncated to the new size * @trans: A transaction handle.
* as well. * @root: The root from which to remove items.
* @inode: The inode whose items we want to remove.
* @new_size: The new i_size for the inode. This is only applicable when
* @min_type is BTRFS_EXTENT_DATA_KEY, must be 0 otherwise.
* @min_type: The minimum key type to remove. All keys with a type
* greater than this value are removed and all keys with
* this type are removed only if their offset is >= @new_size.
* *
* min_type is the minimum key type to truncate down to. If set to 0, this * Remove all keys associated with the inode from the given root that have a key
* will kill all the items on this inode, including the INODE_ITEM_KEY. * with a type greater than or equals to @min_type. When @min_type has a value of
* BTRFS_EXTENT_DATA_KEY, only remove file extent items that have an offset value
* greater than or equals to @new_size. If a file extent item that starts before
* @new_size and ends after it is found, its length is adjusted.
*
* Returns: 0 on success, < 0 on error and NEED_TRUNCATE_BLOCK when @min_type is
* BTRFS_EXTENT_DATA_KEY and the caller must truncate the last block.
*/ */
int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment