Skip to content

Commit a779ed7

Browse files
committed
jfs: define xtree root and page independently
In order to make array bounds checking sane, provide a separate definition of the in-inode xtree root and the external xtree page. Signed-off-by: Dave Kleikamp <[email protected]> Tested-by: Manas Ghandat <[email protected]>
1 parent 05d9ea1 commit a779ed7

File tree

6 files changed

+32
-23
lines changed

6 files changed

+32
-23
lines changed

fs/jfs/jfs_dinode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct dinode {
9696
#define di_gengen u._file._u1._imap._gengen
9797

9898
union {
99-
xtpage_t _xtroot;
99+
xtroot_t _xtroot;
100100
struct {
101101
u8 unused[16]; /* 16: */
102102
dxd_t _dxd; /* 16: */

fs/jfs/jfs_imap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ int diWrite(tid_t tid, struct inode *ip)
670670
* This is the special xtree inside the directory for storing
671671
* the directory table
672672
*/
673-
xtpage_t *p, *xp;
673+
xtroot_t *p, *xp;
674674
xad_t *xad;
675675

676676
jfs_ip->xtlid = 0;
@@ -684,7 +684,7 @@ int diWrite(tid_t tid, struct inode *ip)
684684
* copy xtree root from inode to dinode:
685685
*/
686686
p = &jfs_ip->i_xtroot;
687-
xp = (xtpage_t *) &dp->di_dirtable;
687+
xp = (xtroot_t *) &dp->di_dirtable;
688688
lv = ilinelock->lv;
689689
for (n = 0; n < ilinelock->index; n++, lv++) {
690690
memcpy(&xp->xad[lv->offset], &p->xad[lv->offset],
@@ -713,7 +713,7 @@ int diWrite(tid_t tid, struct inode *ip)
713713
* regular file: 16 byte (XAD slot) granularity
714714
*/
715715
if (type & tlckXTREE) {
716-
xtpage_t *p, *xp;
716+
xtroot_t *p, *xp;
717717
xad_t *xad;
718718

719719
/*

fs/jfs/jfs_incore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct jfs_inode_info {
6666
lid_t xtlid; /* lid of xtree lock on directory */
6767
union {
6868
struct {
69-
xtpage_t _xtroot; /* 288: xtree root */
69+
xtroot_t _xtroot; /* 288: xtree root */
7070
struct inomap *_imap; /* 4: inode map header */
7171
} file;
7272
struct {

fs/jfs/jfs_txnmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
783783
if (mp->xflag & COMMIT_PAGE)
784784
p = (xtpage_t *) mp->data;
785785
else
786-
p = &jfs_ip->i_xtroot;
786+
p = (xtpage_t *) &jfs_ip->i_xtroot;
787787
xtlck->lwm.offset =
788788
le16_to_cpu(p->header.nextindex);
789789
}
@@ -1676,7 +1676,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
16761676

16771677
if (tlck->type & tlckBTROOT) {
16781678
lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT);
1679-
p = &JFS_IP(ip)->i_xtroot;
1679+
p = (xtpage_t *) &JFS_IP(ip)->i_xtroot;
16801680
if (S_ISDIR(ip->i_mode))
16811681
lrd->log.redopage.type |=
16821682
cpu_to_le16(LOG_DIR_XTREE);

fs/jfs/jfs_xtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ xtSplitRoot(tid_t tid,
12131213
struct xtlock *xtlck;
12141214
int rc;
12151215

1216-
sp = &JFS_IP(ip)->i_xtroot;
1216+
sp = (xtpage_t *) &JFS_IP(ip)->i_xtroot;
12171217

12181218
INCREMENT(xtStat.split);
12191219

@@ -2098,7 +2098,7 @@ int xtAppend(tid_t tid, /* transaction id */
20982098
*/
20992099
void xtInitRoot(tid_t tid, struct inode *ip)
21002100
{
2101-
xtpage_t *p;
2101+
xtroot_t *p;
21022102

21032103
/*
21042104
* acquire a transaction lock on the root

fs/jfs/jfs_xtree.h

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,33 @@ struct xadlist {
6565
#define XTPAGEMAXSLOT 256
6666
#define XTENTRYSTART 2
6767

68-
/*
69-
* xtree page:
70-
*/
71-
typedef union {
72-
struct xtheader {
73-
__le64 next; /* 8: */
74-
__le64 prev; /* 8: */
68+
struct xtheader {
69+
__le64 next; /* 8: */
70+
__le64 prev; /* 8: */
7571

76-
u8 flag; /* 1: */
77-
u8 rsrvd1; /* 1: */
78-
__le16 nextindex; /* 2: next index = number of entries */
79-
__le16 maxentry; /* 2: max number of entries */
80-
__le16 rsrvd2; /* 2: */
72+
u8 flag; /* 1: */
73+
u8 rsrvd1; /* 1: */
74+
__le16 nextindex; /* 2: next index = number of entries */
75+
__le16 maxentry; /* 2: max number of entries */
76+
__le16 rsrvd2; /* 2: */
8177

82-
pxd_t self; /* 8: self */
83-
} header; /* (32) */
78+
pxd_t self; /* 8: self */
79+
};
8480

81+
/*
82+
* xtree root (in inode):
83+
*/
84+
typedef union {
85+
struct xtheader header;
8586
xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */
87+
} xtroot_t;
88+
89+
/*
90+
* xtree page:
91+
*/
92+
typedef union {
93+
struct xtheader header;
94+
xad_t xad[XTPAGEMAXSLOT]; /* 16 * maxentry: xad array */
8695
} xtpage_t;
8796

8897
/*

0 commit comments

Comments
 (0)