]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: use mapping_mapped to simplify the code
authorHuang Shijie <huangsj@hygon.cn>
Fri, 12 Jun 2026 07:30:32 +0000 (15:30 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 21 Jun 2026 18:37:38 +0000 (11:37 -0700)
Use mapping_mapped() to simplify the code, make the code tidy and clean.

Link: https://lore.kernel.org/20260612073032.33228-1-huangsj@hygon.cn
Signed-off-by: Huang Shijie <huangsj@hygon.cn>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/hugetlbfs/inode.c
mm/memory.c

index 78d61bf2bd9bba1a7a641ef1a29126dd6507eb66..216e1a0dd0b23749977f2c0de181d65797aeae2a 100644 (file)
@@ -614,7 +614,7 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)
 
        i_size_write(inode, offset);
        i_mmap_lock_write(mapping);
-       if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
+       if (mapping_mapped(mapping))
                hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0,
                                      ZAP_FLAG_DROP_MARKER);
        i_mmap_unlock_write(mapping);
@@ -675,7 +675,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
        /* Unmap users of full pages in the hole. */
        if (hole_end > hole_start) {
-               if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
+               if (mapping_mapped(mapping))
                        hugetlb_vmdelete_list(&mapping->i_mmap,
                                              hole_start >> PAGE_SHIFT,
                                              hole_end >> PAGE_SHIFT, 0);
index 56be920c56d742d79ab8982bdad90227a7686f24..ff338c2abe92311b5470acba3f1306e29b028551 100644 (file)
@@ -4386,7 +4386,7 @@ void unmap_mapping_folio(struct folio *folio)
        details.zap_flags = ZAP_FLAG_DROP_MARKER;
 
        i_mmap_lock_read(mapping);
-       if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
+       if (unlikely(mapping_mapped(mapping)))
                unmap_mapping_range_tree(&mapping->i_mmap, first_index,
                                         last_index, &details);
        i_mmap_unlock_read(mapping);
@@ -4416,7 +4416,7 @@ void unmap_mapping_pages(struct address_space *mapping, pgoff_t start,
                last_index = ULONG_MAX;
 
        i_mmap_lock_read(mapping);
-       if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
+       if (unlikely(mapping_mapped(mapping)))
                unmap_mapping_range_tree(&mapping->i_mmap, first_index,
                                         last_index, &details);
        i_mmap_unlock_read(mapping);