Skip to content

Commit aef1ff1

Browse files
committed
Pull jfs updates from David Kleikamp: "One bug fix and some code cleanup" * tag 'jfs-5.19' of https://github.com/kleikamp/linux-shaggy: fs/jfs: Remove dead code fs: jfs: fix possible NULL pointer dereference in dbFree()
2 parents 35cdd86 + e471e59 commit aef1ff1

File tree

10 files changed

+3
-1652
lines changed

10 files changed

+3
-1652
lines changed

fs/jfs/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ jfs-y := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \
1313
resize.o xattr.o ioctl.o
1414

1515
jfs-$(CONFIG_JFS_POSIX_ACL) += acl.o
16-
17-
ccflags-y := -D_JFS_4K

fs/jfs/inode.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,9 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
224224
* this as a hole
225225
*/
226226
goto unlock;
227-
#ifdef _JFS_4K
228227
XADoffset(&xad, lblock64);
229228
XADlength(&xad, xlen);
230229
XADaddress(&xad, xaddr);
231-
#else /* _JFS_4K */
232-
/*
233-
* As long as block size = 4K, this isn't a problem.
234-
* We should mark the whole page not ABNR, but how
235-
* will we know to mark the other blocks BH_New?
236-
*/
237-
BUG();
238-
#endif /* _JFS_4K */
239230
rc = extRecord(ip, &xad);
240231
if (rc)
241232
goto unlock;
@@ -252,7 +243,6 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
252243
/*
253244
* Allocate a new block
254245
*/
255-
#ifdef _JFS_4K
256246
if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad)))
257247
goto unlock;
258248
rc = extAlloc(ip, xlen, lblock64, &xad, false);
@@ -263,14 +253,6 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
263253
map_bh(bh_result, ip->i_sb, addressXAD(&xad));
264254
bh_result->b_size = lengthXAD(&xad) << ip->i_blkbits;
265255

266-
#else /* _JFS_4K */
267-
/*
268-
* We need to do whatever it takes to keep all but the last buffers
269-
* in 4K pages - see jfs_write.c
270-
*/
271-
BUG();
272-
#endif /* _JFS_4K */
273-
274256
unlock:
275257
/*
276258
* Release lock on inode

fs/jfs/jfs_dmap.c

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks)
385385
}
386386

387387
/* write the last buffer. */
388-
write_metapage(mp);
388+
if (mp)
389+
write_metapage(mp);
389390

390391
IREAD_UNLOCK(ipbmap);
391392

@@ -868,74 +869,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
868869
return (rc);
869870
}
870871

871-
#ifdef _NOTYET
872-
/*
873-
* NAME: dbAllocExact()
874-
*
875-
* FUNCTION: try to allocate the requested extent;
876-
*
877-
* PARAMETERS:
878-
* ip - pointer to in-core inode;
879-
* blkno - extent address;
880-
* nblocks - extent length;
881-
*
882-
* RETURN VALUES:
883-
* 0 - success
884-
* -ENOSPC - insufficient disk resources
885-
* -EIO - i/o error
886-
*/
887-
int dbAllocExact(struct inode *ip, s64 blkno, int nblocks)
888-
{
889-
int rc;
890-
struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;
891-
struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
892-
struct dmap *dp;
893-
s64 lblkno;
894-
struct metapage *mp;
895-
896-
IREAD_LOCK(ipbmap, RDWRLOCK_DMAP);
897-
898-
/*
899-
* validate extent request:
900-
*
901-
* note: defragfs policy:
902-
* max 64 blocks will be moved.
903-
* allocation request size must be satisfied from a single dmap.
904-
*/
905-
if (nblocks <= 0 || nblocks > BPERDMAP || blkno >= bmp->db_mapsize) {
906-
IREAD_UNLOCK(ipbmap);
907-
return -EINVAL;
908-
}
909-
910-
if (nblocks > ((s64) 1 << bmp->db_maxfreebud)) {
911-
/* the free space is no longer available */
912-
IREAD_UNLOCK(ipbmap);
913-
return -ENOSPC;
914-
}
915-
916-
/* read in the dmap covering the extent */
917-
lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
918-
mp = read_metapage(ipbmap, lblkno, PSIZE, 0);
919-
if (mp == NULL) {
920-
IREAD_UNLOCK(ipbmap);
921-
return -EIO;
922-
}
923-
dp = (struct dmap *) mp->data;
924-
925-
/* try to allocate the requested extent */
926-
rc = dbAllocNext(bmp, dp, blkno, nblocks);
927-
928-
IREAD_UNLOCK(ipbmap);
929-
930-
if (rc == 0)
931-
mark_metapage_dirty(mp);
932-
933-
release_metapage(mp);
934-
935-
return (rc);
936-
}
937-
#endif /* _NOTYET */
938-
939872
/*
940873
* NAME: dbReAlloc()
941874
*

0 commit comments

Comments
 (0)