Merge tag 'mm-stable-2022-08-03' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / mm / shmem.c
index 06871a913b49b127ac5c59ce0c7ac3ddd043a688..e975fcd9d2e1ac4de7e841c7147421a9d02fcee8 100644 (file)
@@ -393,7 +393,7 @@ void shmem_uncharge(struct inode *inode, long pages)
        struct shmem_inode_info *info = SHMEM_I(inode);
        unsigned long flags;
 
-       /* nrpages adjustment done by __delete_from_page_cache() or caller */
+       /* nrpages adjustment done by __filemap_remove_folio() or caller */
 
        spin_lock_irqsave(&info->lock, flags);
        info->alloced -= pages;
@@ -694,7 +694,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
 /*
- * Like add_to_page_cache_locked, but error if expected item has gone.
+ * Like filemap_add_folio, but error if expected item has gone.
  */
 static int shmem_add_to_page_cache(struct folio *folio,
                                   struct address_space *mapping,
@@ -868,18 +868,17 @@ unsigned long shmem_swap_usage(struct vm_area_struct *vma)
  */
 void shmem_unlock_mapping(struct address_space *mapping)
 {
-       struct pagevec pvec;
+       struct folio_batch fbatch;
        pgoff_t index = 0;
 
-       pagevec_init(&pvec);
+       folio_batch_init(&fbatch);
        /*
         * Minor point, but we might as well stop if someone else SHM_LOCKs it.
         */
-       while (!mapping_unevictable(mapping)) {
-               if (!pagevec_lookup(&pvec, mapping, &index))
-                       break;
-               check_move_unevictable_pages(&pvec);
-               pagevec_release(&pvec);
+       while (!mapping_unevictable(mapping) &&
+              filemap_get_folios(mapping, &index, ~0UL, &fbatch)) {
+               check_move_unevictable_folios(&fbatch);
+               folio_batch_release(&fbatch);
                cond_resched();
        }
 }
@@ -3450,7 +3449,7 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param)
                break;
        case Opt_nr_blocks:
                ctx->blocks = memparse(param->string, &rest);
-               if (*rest)
+               if (*rest || ctx->blocks > S64_MAX)
                        goto bad_value;
                ctx->seen |= SHMEM_SEEN_BLOCKS;
                break;
@@ -3572,10 +3571,7 @@ static int shmem_reconfigure(struct fs_context *fc)
 
        raw_spin_lock(&sbinfo->stat_lock);
        inodes = sbinfo->max_inodes - sbinfo->free_inodes;
-       if (ctx->blocks > S64_MAX) {
-               err = "Number of blocks too large";
-               goto out;
-       }
+
        if ((ctx->seen & SHMEM_SEEN_BLOCKS) && ctx->blocks) {
                if (!sbinfo->max_blocks) {
                        err = "Cannot retroactively limit size";
@@ -3860,7 +3856,7 @@ const struct address_space_operations shmem_aops = {
        .write_end      = shmem_write_end,
 #endif
 #ifdef CONFIG_MIGRATION
-       .migratepage    = migrate_page,
+       .migrate_folio  = migrate_folio,
 #endif
        .error_remove_page = shmem_error_remove_page,
 };