mirror of
https://gitee.com/bianbu-linux/linux-6.6-fh
synced 2025-04-25 07:57:06 -04:00
jfs: define xtree root and page independently
commit a779ed754e52d582b8c0e17959df063108bd0656 upstream. 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 <dave.kleikamp@oracle.com> Tested-by: Manas Ghandat <ghandatmanas@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
34ba4f29f3
commit
2ff51719ec
6 changed files with 32 additions and 23 deletions
|
@ -96,7 +96,7 @@ struct dinode {
|
||||||
#define di_gengen u._file._u1._imap._gengen
|
#define di_gengen u._file._u1._imap._gengen
|
||||||
|
|
||||||
union {
|
union {
|
||||||
xtpage_t _xtroot;
|
xtroot_t _xtroot;
|
||||||
struct {
|
struct {
|
||||||
u8 unused[16]; /* 16: */
|
u8 unused[16]; /* 16: */
|
||||||
dxd_t _dxd; /* 16: */
|
dxd_t _dxd; /* 16: */
|
||||||
|
|
|
@ -673,7 +673,7 @@ int diWrite(tid_t tid, struct inode *ip)
|
||||||
* This is the special xtree inside the directory for storing
|
* This is the special xtree inside the directory for storing
|
||||||
* the directory table
|
* the directory table
|
||||||
*/
|
*/
|
||||||
xtpage_t *p, *xp;
|
xtroot_t *p, *xp;
|
||||||
xad_t *xad;
|
xad_t *xad;
|
||||||
|
|
||||||
jfs_ip->xtlid = 0;
|
jfs_ip->xtlid = 0;
|
||||||
|
@ -687,7 +687,7 @@ int diWrite(tid_t tid, struct inode *ip)
|
||||||
* copy xtree root from inode to dinode:
|
* copy xtree root from inode to dinode:
|
||||||
*/
|
*/
|
||||||
p = &jfs_ip->i_xtroot;
|
p = &jfs_ip->i_xtroot;
|
||||||
xp = (xtpage_t *) &dp->di_dirtable;
|
xp = (xtroot_t *) &dp->di_dirtable;
|
||||||
lv = ilinelock->lv;
|
lv = ilinelock->lv;
|
||||||
for (n = 0; n < ilinelock->index; n++, lv++) {
|
for (n = 0; n < ilinelock->index; n++, lv++) {
|
||||||
memcpy(&xp->xad[lv->offset], &p->xad[lv->offset],
|
memcpy(&xp->xad[lv->offset], &p->xad[lv->offset],
|
||||||
|
@ -716,7 +716,7 @@ int diWrite(tid_t tid, struct inode *ip)
|
||||||
* regular file: 16 byte (XAD slot) granularity
|
* regular file: 16 byte (XAD slot) granularity
|
||||||
*/
|
*/
|
||||||
if (type & tlckXTREE) {
|
if (type & tlckXTREE) {
|
||||||
xtpage_t *p, *xp;
|
xtroot_t *p, *xp;
|
||||||
xad_t *xad;
|
xad_t *xad;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct jfs_inode_info {
|
||||||
lid_t xtlid; /* lid of xtree lock on directory */
|
lid_t xtlid; /* lid of xtree lock on directory */
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
xtpage_t _xtroot; /* 288: xtree root */
|
xtroot_t _xtroot; /* 288: xtree root */
|
||||||
struct inomap *_imap; /* 4: inode map header */
|
struct inomap *_imap; /* 4: inode map header */
|
||||||
} file;
|
} file;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -783,7 +783,7 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
|
||||||
if (mp->xflag & COMMIT_PAGE)
|
if (mp->xflag & COMMIT_PAGE)
|
||||||
p = (xtpage_t *) mp->data;
|
p = (xtpage_t *) mp->data;
|
||||||
else
|
else
|
||||||
p = &jfs_ip->i_xtroot;
|
p = (xtpage_t *) &jfs_ip->i_xtroot;
|
||||||
xtlck->lwm.offset =
|
xtlck->lwm.offset =
|
||||||
le16_to_cpu(p->header.nextindex);
|
le16_to_cpu(p->header.nextindex);
|
||||||
}
|
}
|
||||||
|
@ -1676,7 +1676,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
|
||||||
|
|
||||||
if (tlck->type & tlckBTROOT) {
|
if (tlck->type & tlckBTROOT) {
|
||||||
lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT);
|
lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT);
|
||||||
p = &JFS_IP(ip)->i_xtroot;
|
p = (xtpage_t *) &JFS_IP(ip)->i_xtroot;
|
||||||
if (S_ISDIR(ip->i_mode))
|
if (S_ISDIR(ip->i_mode))
|
||||||
lrd->log.redopage.type |=
|
lrd->log.redopage.type |=
|
||||||
cpu_to_le16(LOG_DIR_XTREE);
|
cpu_to_le16(LOG_DIR_XTREE);
|
||||||
|
|
|
@ -1213,7 +1213,7 @@ xtSplitRoot(tid_t tid,
|
||||||
struct xtlock *xtlck;
|
struct xtlock *xtlck;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
sp = &JFS_IP(ip)->i_xtroot;
|
sp = (xtpage_t *) &JFS_IP(ip)->i_xtroot;
|
||||||
|
|
||||||
INCREMENT(xtStat.split);
|
INCREMENT(xtStat.split);
|
||||||
|
|
||||||
|
@ -2098,7 +2098,7 @@ int xtAppend(tid_t tid, /* transaction id */
|
||||||
*/
|
*/
|
||||||
void xtInitRoot(tid_t tid, struct inode *ip)
|
void xtInitRoot(tid_t tid, struct inode *ip)
|
||||||
{
|
{
|
||||||
xtpage_t *p;
|
xtroot_t *p;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* acquire a transaction lock on the root
|
* acquire a transaction lock on the root
|
||||||
|
|
|
@ -65,10 +65,6 @@ struct xadlist {
|
||||||
#define XTPAGEMAXSLOT 256
|
#define XTPAGEMAXSLOT 256
|
||||||
#define XTENTRYSTART 2
|
#define XTENTRYSTART 2
|
||||||
|
|
||||||
/*
|
|
||||||
* xtree page:
|
|
||||||
*/
|
|
||||||
typedef union {
|
|
||||||
struct xtheader {
|
struct xtheader {
|
||||||
__le64 next; /* 8: */
|
__le64 next; /* 8: */
|
||||||
__le64 prev; /* 8: */
|
__le64 prev; /* 8: */
|
||||||
|
@ -80,9 +76,22 @@ typedef union {
|
||||||
__le16 rsrvd2; /* 2: */
|
__le16 rsrvd2; /* 2: */
|
||||||
|
|
||||||
pxd_t self; /* 8: self */
|
pxd_t self; /* 8: self */
|
||||||
} header; /* (32) */
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xtree root (in inode):
|
||||||
|
*/
|
||||||
|
typedef union {
|
||||||
|
struct xtheader header;
|
||||||
xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */
|
xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */
|
||||||
|
} xtroot_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xtree page:
|
||||||
|
*/
|
||||||
|
typedef union {
|
||||||
|
struct xtheader header;
|
||||||
|
xad_t xad[XTPAGEMAXSLOT]; /* 16 * maxentry: xad array */
|
||||||
} xtpage_t;
|
} xtpage_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue