Skip to content

Commit 56c003e

Browse files
committed
Pull jfs updates from David Kleikamp: "Assorted JFS fixes for 6.2" * tag 'jfs-6.2' of https://github.com/kleikamp/linux-shaggy: jfs: makes diUnmount/diMount in jfs_mount_rw atomic jfs: Fix a typo in function jfs_umount fs: jfs: fix shift-out-of-bounds in dbDiscardAG jfs: Fix fortify moan in symlink jfs: remove redundant assignments to ipaimap and ipaimap2 jfs: remove unused declarations for jfs fs/jfs/jfs_xattr.h: Fix spelling typo in comment MAINTAINERS: git://github -> https://github.com for kleikamp fs/jfs: replace ternary operator with min_t() fs: jfs: fix shift-out-of-bounds in dbAllocAG
2 parents cda6a60 + a60dca7 commit 56c003e

File tree

10 files changed

+33
-24
lines changed

10 files changed

+33
-24
lines changed

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10993,9 +10993,9 @@ F: drivers/hwmon/jc42.c
1099310993
JFS FILESYSTEM
1099410994
M: Dave Kleikamp <[email protected]>
1099510995
10996-
S: Maintained
10996+
S: Odd Fixes
1099710997
W: http://jfs.sourceforge.net/
10998-
T: git git://github.com/kleikamp/linux-shaggy.git
10998+
T: git https://github.com/kleikamp/linux-shaggy.git
1099910999
F: Documentation/admin-guide/jfs.rst
1100011000
F: fs/jfs/
1100111001

fs/jfs/jfs_dmap.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int dbMount(struct inode *ipbmap)
155155
struct bmap *bmp;
156156
struct dbmap_disk *dbmp_le;
157157
struct metapage *mp;
158-
int i;
158+
int i, err;
159159

160160
/*
161161
* allocate/initialize the in-memory bmap descriptor
@@ -170,8 +170,8 @@ int dbMount(struct inode *ipbmap)
170170
BMAPBLKNO << JFS_SBI(ipbmap->i_sb)->l2nbperpage,
171171
PSIZE, 0);
172172
if (mp == NULL) {
173-
kfree(bmp);
174-
return -EIO;
173+
err = -EIO;
174+
goto err_kfree_bmp;
175175
}
176176

177177
/* copy the on-disk bmap descriptor to its in-memory version. */
@@ -181,9 +181,8 @@ int dbMount(struct inode *ipbmap)
181181
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
182182
bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
183183
if (!bmp->db_numag) {
184-
release_metapage(mp);
185-
kfree(bmp);
186-
return -EINVAL;
184+
err = -EINVAL;
185+
goto err_release_metapage;
187186
}
188187

189188
bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
@@ -194,6 +193,16 @@ int dbMount(struct inode *ipbmap)
194193
bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth);
195194
bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart);
196195
bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size);
196+
if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG) {
197+
err = -EINVAL;
198+
goto err_release_metapage;
199+
}
200+
201+
if (((bmp->db_mapsize - 1) >> bmp->db_agl2size) > MAXAG) {
202+
err = -EINVAL;
203+
goto err_release_metapage;
204+
}
205+
197206
for (i = 0; i < MAXAG; i++)
198207
bmp->db_agfree[i] = le64_to_cpu(dbmp_le->dn_agfree[i]);
199208
bmp->db_agsize = le64_to_cpu(dbmp_le->dn_agsize);
@@ -214,6 +223,12 @@ int dbMount(struct inode *ipbmap)
214223
BMAP_LOCK_INIT(bmp);
215224

216225
return (0);
226+
227+
err_release_metapage:
228+
release_metapage(mp);
229+
err_kfree_bmp:
230+
kfree(bmp);
231+
return err;
217232
}
218233

219234

fs/jfs/jfs_extent.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
(addressPXD(&(JFS_IP(ip)->ixpxd)) + lengthPXD(&(JFS_IP(ip)->ixpxd)) - 1)
1111

1212
extern int extAlloc(struct inode *, s64, s64, xad_t *, bool);
13-
extern int extFill(struct inode *, xad_t *);
1413
extern int extHint(struct inode *, s64, xad_t *);
15-
extern int extRealloc(struct inode *, s64, xad_t *, bool);
1614
extern int extRecord(struct inode *, xad_t *);
1715

1816
#endif /* _H_JFS_EXTENT */

fs/jfs/jfs_imap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ int diRead(struct inode *ip)
310310
iagno = INOTOIAG(ip->i_ino);
311311

312312
/* read the iag */
313-
imap = JFS_IP(ipimap)->i_imap;
314313
IREAD_LOCK(ipimap, RDWRLOCK_IMAP);
314+
imap = JFS_IP(ipimap)->i_imap;
315315
rc = diIAGRead(imap, iagno, &mp);
316316
IREAD_UNLOCK(ipimap);
317317
if (rc) {

fs/jfs/jfs_mount.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,15 @@ int jfs_mount_rw(struct super_block *sb, int remount)
234234

235235
truncate_inode_pages(sbi->ipimap->i_mapping, 0);
236236
truncate_inode_pages(sbi->ipbmap->i_mapping, 0);
237+
238+
IWRITE_LOCK(sbi->ipimap, RDWRLOCK_IMAP);
237239
diUnmount(sbi->ipimap, 1);
238240
if ((rc = diMount(sbi->ipimap))) {
241+
IWRITE_UNLOCK(sbi->ipimap);
239242
jfs_err("jfs_mount_rw: diMount failed!");
240243
return rc;
241244
}
245+
IWRITE_UNLOCK(sbi->ipimap);
242246

243247
dbUnmount(sbi->ipbmap, 1);
244248
if ((rc = dbMount(sbi->ipbmap))) {

fs/jfs/jfs_umount.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ int jfs_umount(struct super_block *sb)
6868
/*
6969
* close secondary aggregate inode allocation map
7070
*/
71-
ipaimap2 = sbi->ipaimap2;
7271
if (ipaimap2) {
7372
diUnmount(ipaimap2, 0);
7473
diFreeSpecial(ipaimap2);
@@ -78,7 +77,6 @@ int jfs_umount(struct super_block *sb)
7877
/*
7978
* close aggregate inode allocation map
8079
*/
81-
ipaimap = sbi->ipaimap;
8280
diUnmount(ipaimap, 0);
8381
diFreeSpecial(ipaimap);
8482
sbi->ipaimap = NULL;
@@ -89,7 +87,7 @@ int jfs_umount(struct super_block *sb)
8987
dbUnmount(ipbmap, 0);
9088

9189
diFreeSpecial(ipbmap);
92-
sbi->ipimap = NULL;
90+
sbi->ipbmap = NULL;
9391

9492
/*
9593
* Make sure all metadata makes it to disk before we mark

fs/jfs/jfs_xattr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct jfs_ea_list {
2525
struct jfs_ea ea[]; /* Variable length list */
2626
};
2727

28-
/* Macros for defining maxiumum number of bytes supported for EAs */
28+
/* Macros for defining maximum number of bytes supported for EAs */
2929
#define MAXEASIZE 65535
3030
#define MAXEALISTSIZE MAXEASIZE
3131

fs/jfs/jfs_xtree.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,8 @@ extern int xtInsert(tid_t tid, struct inode *ip,
9696
extern int xtExtend(tid_t tid, struct inode *ip, s64 xoff, int xlen,
9797
int flag);
9898
extern int xtUpdate(tid_t tid, struct inode *ip, struct xad *nxad);
99-
extern int xtDelete(tid_t tid, struct inode *ip, s64 xoff, int xlen,
100-
int flag);
10199
extern s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int type);
102100
extern s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size);
103-
extern int xtRelocate(tid_t tid, struct inode *ip,
104-
xad_t * oxad, s64 nxaddr, int xtype);
105101
extern int xtAppend(tid_t tid,
106102
struct inode *ip, int xflag, s64 xoff, int maxblocks,
107103
int *xlenp, s64 * xaddrp, int flag);

fs/jfs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int jfs_symlink(struct user_namespace *mnt_userns, struct inode *dip,
946946
if (ssize <= IDATASIZE) {
947947
ip->i_op = &jfs_fast_symlink_inode_operations;
948948

949-
ip->i_link = JFS_IP(ip)->i_inline;
949+
ip->i_link = JFS_IP(ip)->i_inline_all;
950950
memcpy(ip->i_link, name, ssize);
951951
ip->i_size = ssize - 1;
952952

fs/jfs/super.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,7 @@ static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
745745
len = i_size-off;
746746
toread = len;
747747
while (toread > 0) {
748-
tocopy = sb->s_blocksize - offset < toread ?
749-
sb->s_blocksize - offset : toread;
748+
tocopy = min_t(size_t, sb->s_blocksize - offset, toread);
750749

751750
tmp_bh.b_state = 0;
752751
tmp_bh.b_size = i_blocksize(inode);
@@ -785,8 +784,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
785784

786785
inode_lock(inode);
787786
while (towrite > 0) {
788-
tocopy = sb->s_blocksize - offset < towrite ?
789-
sb->s_blocksize - offset : towrite;
787+
tocopy = min_t(size_t, sb->s_blocksize - offset, towrite);
790788

791789
tmp_bh.b_state = 0;
792790
tmp_bh.b_size = i_blocksize(inode);

0 commit comments

Comments
 (0)