Skip to content

Commit 706ce3c

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-05-06-10-45' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull hotfixes from Andrew Morton: "Five hotfixes. Three are cc:stable, two pertain to merge window changes" * tag 'mm-hotfixes-stable-2023-05-06-10-45' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: afs: fix the afs_dir_get_folio return value nilfs2: do not write dirty data after degenerating to read-only mm: do not reclaim private data from pinned page nilfs2: fix infinite loop in nilfs_mdt_get_block() mm/mmap/vma_merge: always check invariants
2 parents 994e241 + 58f5f66 commit 706ce3c

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

fs/afs/dir_edit.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ static struct folio *afs_dir_get_folio(struct afs_vnode *vnode, pgoff_t index)
115115
folio = __filemap_get_folio(mapping, index,
116116
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
117117
mapping->gfp_mask);
118-
if (IS_ERR(folio))
118+
if (IS_ERR(folio)) {
119119
clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags);
120-
else if (folio && !folio_test_private(folio))
120+
return NULL;
121+
}
122+
if (!folio_test_private(folio))
121123
folio_attach_private(folio, (void *)1);
122-
123124
return folio;
124125
}
125126

fs/nilfs2/bmap.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,28 @@ int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level,
6767

6868
down_read(&bmap->b_sem);
6969
ret = bmap->b_ops->bop_lookup(bmap, key, level, ptrp);
70-
if (ret < 0) {
71-
ret = nilfs_bmap_convert_error(bmap, __func__, ret);
70+
if (ret < 0)
7271
goto out;
73-
}
72+
7473
if (NILFS_BMAP_USE_VBN(bmap)) {
7574
ret = nilfs_dat_translate(nilfs_bmap_get_dat(bmap), *ptrp,
7675
&blocknr);
7776
if (!ret)
7877
*ptrp = blocknr;
78+
else if (ret == -ENOENT) {
79+
/*
80+
* If there was no valid entry in DAT for the block
81+
* address obtained by b_ops->bop_lookup, then pass
82+
* internal code -EINVAL to nilfs_bmap_convert_error
83+
* to treat it as metadata corruption.
84+
*/
85+
ret = -EINVAL;
86+
}
7987
}
8088

8189
out:
8290
up_read(&bmap->b_sem);
83-
return ret;
91+
return nilfs_bmap_convert_error(bmap, __func__, ret);
8492
}
8593

8694
int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,

fs/nilfs2/segment.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,9 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
20412041
struct the_nilfs *nilfs = sci->sc_super->s_fs_info;
20422042
int err;
20432043

2044+
if (sb_rdonly(sci->sc_super))
2045+
return -EROFS;
2046+
20442047
nilfs_sc_cstage_set(sci, NILFS_ST_INIT);
20452048
sci->sc_cno = nilfs->ns_cno;
20462049

@@ -2724,7 +2727,7 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci)
27242727

27252728
flush_work(&sci->sc_iput_work);
27262729

2727-
} while (ret && retrycount-- > 0);
2730+
} while (ret && ret != -EROFS && retrycount-- > 0);
27282731
}
27292732

27302733
/**

mm/mmap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,17 +960,17 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,
960960
merge_next = true;
961961
}
962962

963+
/* Verify some invariant that must be enforced by the caller. */
964+
VM_WARN_ON(prev && addr <= prev->vm_start);
965+
VM_WARN_ON(curr && (addr != curr->vm_start || end > curr->vm_end));
966+
VM_WARN_ON(addr >= end);
967+
963968
if (!merge_prev && !merge_next)
964969
return NULL; /* Not mergeable. */
965970

966971
res = vma = prev;
967972
remove = remove2 = adjust = NULL;
968973

969-
/* Verify some invariant that must be enforced by the caller. */
970-
VM_WARN_ON(prev && addr <= prev->vm_start);
971-
VM_WARN_ON(curr && (addr != curr->vm_start || end > curr->vm_end));
972-
VM_WARN_ON(addr >= end);
973-
974974
/* Can we merge both the predecessor and the successor? */
975975
if (merge_prev && merge_next &&
976976
is_mergeable_anon_vma(prev->anon_vma, next->anon_vma, NULL)) {

mm/vmscan.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,16 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
19671967
}
19681968
}
19691969

1970+
/*
1971+
* Folio is unmapped now so it cannot be newly pinned anymore.
1972+
* No point in trying to reclaim folio if it is pinned.
1973+
* Furthermore we don't want to reclaim underlying fs metadata
1974+
* if the folio is pinned and thus potentially modified by the
1975+
* pinning process as that may upset the filesystem.
1976+
*/
1977+
if (folio_maybe_dma_pinned(folio))
1978+
goto activate_locked;
1979+
19701980
mapping = folio_mapping(folio);
19711981
if (folio_test_dirty(folio)) {
19721982
/*

0 commit comments

Comments
 (0)