summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2021-05-31 10:37:03 +0300
committerDavid Sterba <dsterba@suse.com>2021-06-21 15:19:07 +0200
commitec87b42f7095a92e484e34c2c9bb486ae79d6548 (patch)
treeefc89545f5b39d978604feca6ae9719e4876fb93
parent4183abf6cbfd8e71c5e19df697d8e43f1a2a6908 (diff)
downloadlinux-ec87b42f7095a92e484e34c2c9bb486ae79d6548.tar.bz2
btrfs: use list_last_entry in add_falloc_range
Instead of calling list_entry with head->prev simply call list_last_entry which makes it obvious which member of the list is being referred. This allows to remove the extra 'prev' pointer. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/file.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 55f68422061d..a56a13999bd6 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -3034,7 +3034,6 @@ struct falloc_range {
*/
static int add_falloc_range(struct list_head *head, u64 start, u64 len)
{
- struct falloc_range *prev = NULL;
struct falloc_range *range = NULL;
if (list_empty(head))
@@ -3044,9 +3043,9 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
* As fallocate iterate by bytenr order, we only need to check
* the last range.
*/
- prev = list_entry(head->prev, struct falloc_range, list);
- if (prev->start + prev->len == start) {
- prev->len += len;
+ range = list_last_entry(head, struct falloc_range, list);
+ if (range->start + range->len == start) {
+ range->len += len;
return 0;
}
insert: