Commit 371c1414 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'jfs-6.11' of github.com:kleikamp/linux-shaggy

Pull jfs updates from David Kleikamp:
 "Folio conversion from Matthew Wilcox and a few various fixes"

* tag 'jfs-6.11' of github.com:kleikamp/linux-shaggy:
  jfs: don't walk off the end of ealist
  jfs: Fix shift-out-of-bounds in dbDiscardAG
  jfs: Fix array-index-out-of-bounds in diFree
  jfs: fix null ptr deref in dtInsertEntry
  jfs: Remove use of folio error flag
  fs: Remove i_blocks_per_page
  jfs: Change metapage->page to metapage->folio
  jfs: Convert force_metapage to use a folio
  jfs: Convert inc_io to take a folio
  jfs: Convert page_to_mp to folio_to_mp
  jfs; Convert __invalidate_metapages to use a folio
  jfs: Convert dec_io to take a folio
  jfs: Convert drop_metapage and remove_metapage to take a folio
  jfs; Convert release_metapage to use a folio
  jfs: Convert insert_metapage() to take a folio
  jfs: Convert __get_metapage to use a folio
  jfs: Convert metapage_writepage to metapage_write_folio
  jfs: Convert metapage_read_folio to use folio APIs
parents ca83c61c d0fa70ac
...@@ -1626,6 +1626,8 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) ...@@ -1626,6 +1626,8 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
} else if (rc == -ENOSPC) { } else if (rc == -ENOSPC) {
/* search for next smaller log2 block */ /* search for next smaller log2 block */
l2nb = BLKSTOL2(nblocks) - 1; l2nb = BLKSTOL2(nblocks) - 1;
if (unlikely(l2nb < 0))
break;
nblocks = 1LL << l2nb; nblocks = 1LL << l2nb;
} else { } else {
/* Trim any already allocated blocks */ /* Trim any already allocated blocks */
......
...@@ -834,6 +834,8 @@ int dtInsert(tid_t tid, struct inode *ip, ...@@ -834,6 +834,8 @@ int dtInsert(tid_t tid, struct inode *ip,
* the full page. * the full page.
*/ */
DT_GETSEARCH(ip, btstack->top, bn, mp, p, index); DT_GETSEARCH(ip, btstack->top, bn, mp, p, index);
if (p->header.freelist == 0)
return -EINVAL;
/* /*
* insert entry for new key * insert entry for new key
......
...@@ -290,7 +290,7 @@ int diSync(struct inode *ipimap) ...@@ -290,7 +290,7 @@ int diSync(struct inode *ipimap)
int diRead(struct inode *ip) int diRead(struct inode *ip)
{ {
struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
int iagno, ino, extno, rc; int iagno, ino, extno, rc, agno;
struct inode *ipimap; struct inode *ipimap;
struct dinode *dp; struct dinode *dp;
struct iag *iagp; struct iag *iagp;
...@@ -339,8 +339,11 @@ int diRead(struct inode *ip) ...@@ -339,8 +339,11 @@ int diRead(struct inode *ip)
/* get the ag for the iag */ /* get the ag for the iag */
agstart = le64_to_cpu(iagp->agstart); agstart = le64_to_cpu(iagp->agstart);
agno = BLKTOAG(agstart, JFS_SBI(ip->i_sb));
release_metapage(mp); release_metapage(mp);
if (agno >= MAXAG || agno < 0)
return -EIO;
rel_inode = (ino & (INOSPERPAGE - 1)); rel_inode = (ino & (INOSPERPAGE - 1));
pageno = blkno >> sbi->l2nbperpage; pageno = blkno >> sbi->l2nbperpage;
......
...@@ -1600,7 +1600,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait) ...@@ -1600,7 +1600,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
mp, sizeof(struct metapage), 0); mp, sizeof(struct metapage), 0);
print_hex_dump(KERN_ERR, "page: ", print_hex_dump(KERN_ERR, "page: ",
DUMP_PREFIX_ADDRESS, 16, DUMP_PREFIX_ADDRESS, 16,
sizeof(long), mp->page, sizeof(long), mp->folio,
sizeof(struct page), 0); sizeof(struct page), 0);
} else } else
print_hex_dump(KERN_ERR, "tblock:", print_hex_dump(KERN_ERR, "tblock:",
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ struct metapage { ...@@ -24,7 +24,7 @@ struct metapage {
wait_queue_head_t wait; wait_queue_head_t wait;
/* implementation */ /* implementation */
struct page *page; struct folio *folio;
struct super_block *sb; struct super_block *sb;
unsigned int logical_size; unsigned int logical_size;
...@@ -90,14 +90,14 @@ static inline void discard_metapage(struct metapage *mp) ...@@ -90,14 +90,14 @@ static inline void discard_metapage(struct metapage *mp)
static inline void metapage_nohomeok(struct metapage *mp) static inline void metapage_nohomeok(struct metapage *mp)
{ {
struct page *page = mp->page; struct folio *folio = mp->folio;
lock_page(page); folio_lock(folio);
if (!mp->nohomeok++) { if (!mp->nohomeok++) {
mark_metapage_dirty(mp); mark_metapage_dirty(mp);
get_page(page); folio_get(folio);
wait_on_page_writeback(page); folio_wait_writeback(folio);
} }
unlock_page(page); folio_unlock(folio);
} }
/* /*
...@@ -107,7 +107,7 @@ static inline void metapage_nohomeok(struct metapage *mp) ...@@ -107,7 +107,7 @@ static inline void metapage_nohomeok(struct metapage *mp)
static inline void metapage_wait_for_io(struct metapage *mp) static inline void metapage_wait_for_io(struct metapage *mp)
{ {
if (test_bit(META_io, &mp->flag)) if (test_bit(META_io, &mp->flag))
wait_on_page_writeback(mp->page); folio_wait_writeback(mp->folio);
} }
/* /*
...@@ -116,7 +116,7 @@ static inline void metapage_wait_for_io(struct metapage *mp) ...@@ -116,7 +116,7 @@ static inline void metapage_wait_for_io(struct metapage *mp)
static inline void _metapage_homeok(struct metapage *mp) static inline void _metapage_homeok(struct metapage *mp)
{ {
if (!--mp->nohomeok) if (!--mp->nohomeok)
put_page(mp->page); folio_put(mp->folio);
} }
static inline void metapage_homeok(struct metapage *mp) static inline void metapage_homeok(struct metapage *mp)
......
...@@ -797,7 +797,7 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data, ...@@ -797,7 +797,7 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
size_t buf_size) size_t buf_size)
{ {
struct jfs_ea_list *ealist; struct jfs_ea_list *ealist;
struct jfs_ea *ea; struct jfs_ea *ea, *ealist_end;
struct ea_buffer ea_buf; struct ea_buffer ea_buf;
int xattr_size; int xattr_size;
ssize_t size; ssize_t size;
...@@ -817,9 +817,16 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data, ...@@ -817,9 +817,16 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
goto not_found; goto not_found;
ealist = (struct jfs_ea_list *) ea_buf.xattr; ealist = (struct jfs_ea_list *) ea_buf.xattr;
ealist_end = END_EALIST(ealist);
/* Find the named attribute */ /* Find the named attribute */
for (ea = FIRST_EA(ealist); ea < END_EALIST(ealist); ea = NEXT_EA(ea)) for (ea = FIRST_EA(ealist); ea < ealist_end; ea = NEXT_EA(ea)) {
if (unlikely(ea + 1 > ealist_end) ||
unlikely(NEXT_EA(ea) > ealist_end)) {
size = -EUCLEAN;
goto release;
}
if ((namelen == ea->namelen) && if ((namelen == ea->namelen) &&
memcmp(name, ea->name, namelen) == 0) { memcmp(name, ea->name, namelen) == 0) {
/* Found it */ /* Found it */
...@@ -834,6 +841,7 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data, ...@@ -834,6 +841,7 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
memcpy(data, value, size); memcpy(data, value, size);
goto release; goto release;
} }
}
not_found: not_found:
size = -ENODATA; size = -ENODATA;
release: release:
...@@ -861,7 +869,7 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size) ...@@ -861,7 +869,7 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size)
ssize_t size = 0; ssize_t size = 0;
int xattr_size; int xattr_size;
struct jfs_ea_list *ealist; struct jfs_ea_list *ealist;
struct jfs_ea *ea; struct jfs_ea *ea, *ealist_end;
struct ea_buffer ea_buf; struct ea_buffer ea_buf;
down_read(&JFS_IP(inode)->xattr_sem); down_read(&JFS_IP(inode)->xattr_sem);
...@@ -876,9 +884,16 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size) ...@@ -876,9 +884,16 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size)
goto release; goto release;
ealist = (struct jfs_ea_list *) ea_buf.xattr; ealist = (struct jfs_ea_list *) ea_buf.xattr;
ealist_end = END_EALIST(ealist);
/* compute required size of list */ /* compute required size of list */
for (ea = FIRST_EA(ealist); ea < END_EALIST(ealist); ea = NEXT_EA(ea)) { for (ea = FIRST_EA(ealist); ea < ealist_end; ea = NEXT_EA(ea)) {
if (unlikely(ea + 1 > ealist_end) ||
unlikely(NEXT_EA(ea) > ealist_end)) {
size = -EUCLEAN;
goto release;
}
if (can_list(ea)) if (can_list(ea))
size += name_size(ea) + 1; size += name_size(ea) + 1;
} }
......
...@@ -1537,10 +1537,4 @@ unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio) ...@@ -1537,10 +1537,4 @@ unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio)
{ {
return folio_size(folio) >> inode->i_blkbits; return folio_size(folio) >> inode->i_blkbits;
} }
static inline
unsigned int i_blocks_per_page(struct inode *inode, struct page *page)
{
return i_blocks_per_folio(inode, page_folio(page));
}
#endif /* _LINUX_PAGEMAP_H */ #endif /* _LINUX_PAGEMAP_H */
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