/*
- * Copyright (C) International Business Machines Corp., 2000-2003
+ * Copyright (C) International Business Machines Corp., 2000-2004
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include <linux/pagemap.h>
+#include <linux/quotaops.h>
+#include <linux/vserver/xid.h>
#include "jfs_incore.h"
#include "jfs_filsys.h"
struct inomap *imap;
struct metapage *mp;
int index;
- struct dinomap *dinom_le;
+ struct dinomap_disk *dinom_le;
/*
* allocate/initialize the in-memory inode map control structure
}
/* copy the on-disk version to the in-memory version. */
- dinom_le = (struct dinomap *) mp->data;
+ dinom_le = (struct dinomap_disk *) mp->data;
imap->im_freeiag = le32_to_cpu(dinom_le->in_freeiag);
imap->im_nextiag = le32_to_cpu(dinom_le->in_nextiag);
atomic_set(&imap->im_numinos, le32_to_cpu(dinom_le->in_numinos));
*/
int diSync(struct inode *ipimap)
{
- struct dinomap *dinom_le;
+ struct dinomap_disk *dinom_le;
struct inomap *imp = JFS_IP(ipimap)->i_imap;
struct metapage *mp;
int index;
}
/* copy the in-memory version to the on-disk version */
- dinom_le = (struct dinomap *) mp->data;
+ dinom_le = (struct dinomap_disk *) mp->data;
dinom_le->in_freeiag = cpu_to_le32(imp->im_freeiag);
dinom_le->in_nextiag = cpu_to_le32(imp->im_nextiag);
dinom_le->in_numinos = cpu_to_le32(atomic_read(&imp->im_numinos));
}
- ip->i_mapping->a_ops = &jfs_aops;
+ ip->i_mapping->a_ops = &jfs_metapage_aops;
mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
+ /* Allocations to metadata inodes should not affect quotas */
+ ip->i_flags |= S_NOQUOTA;
+
if ((inum == FILESYSTEM_I) && (JFS_IP(ip)->ipimap == sbi->ipaimap)) {
sbi->gengen = le32_to_cpu(dp->di_gengen);
sbi->inostamp = le32_to_cpu(dp->di_inostamp);
*/
iagp->inofreefwd =
cpu_to_le32(imap->im_agctl[agno].inofree);
- iagp->inofreeback = -1;
+ iagp->inofreeback = cpu_to_le32(-1);
imap->im_agctl[agno].inofree = iagno;
}
IREAD_UNLOCK(ipimap);
* inodes (i.e., the inode being freed is the first free
* inode of extent),
*/
- if (iagp->wmap[extno] == ONES) {
+ if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
sword = extno >> L2EXTSPERSUM;
bitno = extno & (EXTSPERSUM - 1);
iagp->inosmap[sword] &=
iagp->extfreefwd =
cpu_to_le32(imap->im_agctl[agno].extfree);
- iagp->extfreeback = -1;
+ iagp->extfreeback = cpu_to_le32(-1);
imap->im_agctl[agno].extfree = iagno;
} else {
/* remove the iag from the ag extent list if all extents
imap->im_agctl[agno].extfree =
le32_to_cpu(iagp->extfreefwd);
- iagp->extfreefwd = iagp->extfreeback = -1;
+ iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
IAGFREE_LOCK(imap);
iagp->iagfree = cpu_to_le32(imap->im_freeiag);
imap->im_agctl[agno].inofree =
le32_to_cpu(iagp->inofreefwd);
- iagp->inofreefwd = iagp->inofreeback = -1;
+ iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
}
/* update the inode extent address and working map
* to be freed by the transaction;
*/
tid = txBegin(ipimap->i_sb, COMMIT_FORCE);
+ down(&JFS_IP(ipimap)->commit_sem);
/* acquire tlock of the iag page of the freed ixad
* to force the page NOHOMEOK (even though no data is
rc = txCommit(tid, 1, &iplist[0], COMMIT_FORCE);
txEnd(tid);
+ up(&JFS_IP(ipimap)->commit_sem);
/* unlock the AG inode map information */
AG_UNLOCK(imap, agno);
{
int extno, bitno, agno, sword, rc;
struct metapage *amp = NULL, *bmp = NULL;
- struct iag *aiagp = 0, *biagp = 0;
+ struct iag *aiagp = NULL, *biagp = NULL;
u32 mask;
/* check if this is the last free inode within the iag.
* allocated. if so, update the free inode summary
* map to reflect this.
*/
- if (iagp->wmap[extno] == ONES) {
+ if (iagp->wmap[extno] == cpu_to_le32(ONES)) {
sword = extno >> L2EXTSPERSUM;
bitno = extno & (EXTSPERSUM - 1);
iagp->inosmap[sword] |= cpu_to_le32(HIGHORDER >> bitno);
imap->im_agctl[agno].inofree =
le32_to_cpu(iagp->inofreefwd);
}
- iagp->inofreefwd = iagp->inofreeback = -1;
+ iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
}
/* update the free inode count at the iag, ag, inode
static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
{
int agno, iagno, fwd, back, freei = 0, sword, rc;
- struct iag *aiagp = 0, *biagp = 0, *ciagp = 0;
+ struct iag *aiagp = NULL, *biagp = NULL, *ciagp = NULL;
struct metapage *amp, *bmp, *cmp, *dmp;
struct inode *ipimap;
s64 blkno, hint;
imap->im_agctl[agno].extfree =
le32_to_cpu(iagp->extfreefwd);
- iagp->extfreefwd = iagp->extfreeback = -1;
+ iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
} else {
/* if the iag has all free extents (newly allocated iag),
* add the iag to the ag free extent list.
aiagp->extfreeback = cpu_to_le32(iagno);
iagp->extfreefwd = cpu_to_le32(fwd);
- iagp->extfreeback = -1;
+ iagp->extfreeback = cpu_to_le32(-1);
imap->im_agctl[agno].extfree = iagno;
}
}
iagp->inofreefwd =
cpu_to_le32(imap->im_agctl[agno].inofree);
- iagp->inofreeback = -1;
+ iagp->inofreeback = cpu_to_le32(-1);
imap->im_agctl[agno].inofree = iagno;
}
goto out;
}
- /* assign a buffer for the page */
- mp = get_metapage(ipimap, xaddr, PSIZE, 1);
- if (!mp) {
+ /*
+ * start transaction of update of the inode map
+ * addressing structure pointing to the new iag page;
+ */
+ tid = txBegin(sb, COMMIT_FORCE);
+ down(&JFS_IP(ipimap)->commit_sem);
+
+ /* update the inode map addressing structure to point to it */
+ if ((rc =
+ xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
+ txEnd(tid);
+ up(&JFS_IP(ipimap)->commit_sem);
/* Free the blocks allocated for the iag since it was
* not successfully added to the inode map
*/
/* release the inode map lock */
IWRITE_UNLOCK(ipimap);
+ goto out;
+ }
+
+ /* update the inode map's inode to reflect the extension */
+ ipimap->i_size += PSIZE;
+ inode_add_bytes(ipimap, PSIZE);
+
+ /* assign a buffer for the page */
+ mp = get_metapage(ipimap, blkno, PSIZE, 0);
+ if (!mp) {
+ /*
+ * This is very unlikely since we just created the
+ * extent, but let's try to handle it correctly
+ */
+ xtTruncate(tid, ipimap, ipimap->i_size - PSIZE,
+ COMMIT_PWMAP);
+
+ txAbort(tid, 0);
+ txEnd(tid);
+
+ /* release the inode map lock */
+ IWRITE_UNLOCK(ipimap);
+
rc = -EIO;
goto out;
}
/* init the iag */
memset(iagp, 0, sizeof(struct iag));
iagp->iagnum = cpu_to_le32(iagno);
- iagp->inofreefwd = iagp->inofreeback = -1;
- iagp->extfreefwd = iagp->extfreeback = -1;
- iagp->iagfree = -1;
+ iagp->inofreefwd = iagp->inofreeback = cpu_to_le32(-1);
+ iagp->extfreefwd = iagp->extfreeback = cpu_to_le32(-1);
+ iagp->iagfree = cpu_to_le32(-1);
iagp->nfreeinos = 0;
iagp->nfreeexts = cpu_to_le32(EXTSPERIAG);
* summary map initialization handled by bzero).
*/
for (i = 0; i < SMAPSZ; i++)
- iagp->inosmap[i] = ONES;
-
- flush_metapage(mp);
-#ifdef _STILL_TO_PORT
- /* synchronously write the iag page */
- if (bmWrite(bp)) {
- /* Free the blocks allocated for the iag since it was
- * not successfully added to the inode map
- */
- dbFree(ipimap, xaddr, (s64) xlen);
-
- /* release the inode map lock */
- IWRITE_UNLOCK(ipimap);
-
- rc = -EIO;
- goto out;
- }
-
- /* Now the iag is on disk */
+ iagp->inosmap[i] = cpu_to_le32(ONES);
/*
- * start tyransaction of update of the inode map
- * addressing structure pointing to the new iag page;
+ * Write and sync the metapage
*/
-#endif /* _STILL_TO_PORT */
- tid = txBegin(sb, COMMIT_FORCE);
-
- /* update the inode map addressing structure to point to it */
- if ((rc =
- xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
- /* Free the blocks allocated for the iag since it was
- * not successfully added to the inode map
- */
- dbFree(ipimap, xaddr, (s64) xlen);
-
- /* release the inode map lock */
- IWRITE_UNLOCK(ipimap);
-
- goto out;
- }
-
- /* update the inode map's inode to reflect the extension */
- ipimap->i_size += PSIZE;
- ipimap->i_blocks += LBLK2PBLK(sb, xlen);
+ flush_metapage(mp);
/*
* txCommit(COMMIT_FORCE) will synchronously write address
rc = txCommit(tid, 1, &iplist[0], COMMIT_FORCE);
txEnd(tid);
+ up(&JFS_IP(ipimap)->commit_sem);
duplicateIXtree(sb, blkno, xlen, &xaddr);
/* remove the iag from the iag free list */
imap->im_freeiag = le32_to_cpu(iagp->iagfree);
- iagp->iagfree = -1;
+ iagp->iagfree = cpu_to_le32(-1);
/* set the return iag number and buffer pointer */
*iagnop = iagno;
u32 mask;
struct jfs_log *log;
int lsn, difft, diffp;
+ unsigned long flags;
imap = JFS_IP(ipimap)->i_imap;
/* get the iag number containing the inode */
IREAD_UNLOCK(ipimap);
if (rc)
return (rc);
+ metapage_wait_for_io(mp);
iagp = (struct iag *) mp->data;
/* get the inode number and extent number of the inode within
* the iag and the inode number within the extent.
/* inherit older/smaller lsn */
logdiff(difft, lsn, log);
logdiff(diffp, mp->lsn, log);
+ LOGSYNC_LOCK(log, flags);
if (difft < diffp) {
mp->lsn = lsn;
/* move mp after tblock in logsync list */
- LOGSYNC_LOCK(log);
list_move(&mp->synclist, &tblk->synclist);
- LOGSYNC_UNLOCK(log);
}
/* inherit younger/larger clsn */
- LOGSYNC_LOCK(log);
assert(mp->clsn);
logdiff(difft, tblk->clsn, log);
logdiff(diffp, mp->clsn, log);
if (difft > diffp)
mp->clsn = tblk->clsn;
- LOGSYNC_UNLOCK(log);
+ LOGSYNC_UNLOCK(log, flags);
} else {
mp->log = log;
mp->lsn = lsn;
/* insert mp after tblock in logsync list */
- LOGSYNC_LOCK(log);
+ LOGSYNC_LOCK(log, flags);
log->count++;
list_add(&mp->synclist, &tblk->synclist);
mp->clsn = tblk->clsn;
- LOGSYNC_UNLOCK(log);
+ LOGSYNC_UNLOCK(log, flags);
}
write_metapage(mp);
return (0);
{
int rc, rcx = 0;
struct inomap *imap = JFS_IP(ipimap)->i_imap;
- struct iag *iagp = 0, *hiagp = 0;
+ struct iag *iagp = NULL, *hiagp = NULL;
struct bmap *mp = JFS_SBI(ipbmap->i_sb)->bmap;
struct metapage *bp, *hbp;
int i, n, head;
/* init per AG control information im_agctl[] */
for (i = 0; i < MAXAG; i++) {
- imap->im_agctl[i].inofree = -1; /* free inode list */
- imap->im_agctl[i].extfree = -1; /* free extent list */
+ imap->im_agctl[i].inofree = -1;
+ imap->im_agctl[i].extfree = -1;
imap->im_agctl[i].numinos = 0; /* number of backed inodes */
imap->im_agctl[i].numfree = 0; /* number of free backed inodes */
}
/* if any backed free inodes, insert at AG free inode list */
if ((int) le32_to_cpu(iagp->nfreeinos) > 0) {
- if ((head = imap->im_agctl[n].inofree) == -1)
- iagp->inofreefwd = iagp->inofreeback = -1;
- else {
+ if ((head = imap->im_agctl[n].inofree) == -1) {
+ iagp->inofreefwd = cpu_to_le32(-1);
+ iagp->inofreeback = cpu_to_le32(-1);
+ } else {
if ((rc = diIAGRead(imap, head, &hbp))) {
rcx = rc;
goto nextiag;
}
hiagp = (struct iag *) hbp->data;
- hiagp->inofreeback =
- le32_to_cpu(iagp->iagnum);
+ hiagp->inofreeback = iagp->iagnum;
iagp->inofreefwd = cpu_to_le32(head);
- iagp->inofreeback = -1;
+ iagp->inofreeback = cpu_to_le32(-1);
write_metapage(hbp);
}
/* if any free extents, insert at AG free extent list */
if (le32_to_cpu(iagp->nfreeexts) > 0) {
- if ((head = imap->im_agctl[n].extfree) == -1)
- iagp->extfreefwd = iagp->extfreeback = -1;
- else {
+ if ((head = imap->im_agctl[n].extfree) == -1) {
+ iagp->extfreefwd = cpu_to_le32(-1);
+ iagp->extfreeback = cpu_to_le32(-1);
+ } else {
if ((rc = diIAGRead(imap, head, &hbp))) {
rcx = rc;
goto nextiag;
hiagp = (struct iag *) hbp->data;
hiagp->extfreeback = iagp->iagnum;
iagp->extfreefwd = cpu_to_le32(head);
- iagp->extfreeback = -1;
+ iagp->extfreeback = cpu_to_le32(-1);
write_metapage(hbp);
}
if (readSuper(sb, &bh))
return;
j_sb = (struct jfs_superblock *)bh->b_data;
- j_sb->s_flag |= JFS_BAD_SAIT;
+ j_sb->s_flag |= cpu_to_le32(JFS_BAD_SAIT);
mark_buffer_dirty(bh);
sync_dirty_buffer(bh);
}
/* update the inode map's inode to reflect the extension */
ip->i_size += PSIZE;
- ip->i_blocks += LBLK2PBLK(sb, xlen);
+ inode_add_bytes(ip, PSIZE);
txCommit(tid, 1, &ip, COMMIT_FORCE);
cleanup:
txEnd(tid);
static int copy_from_dinode(struct dinode * dip, struct inode *ip)
{
struct jfs_inode_info *jfs_ip = JFS_IP(ip);
+ uid_t uid;
+ gid_t gid;
jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
ip->i_mode = le32_to_cpu(dip->di_mode) & 0xffff;
ip->i_nlink = le32_to_cpu(dip->di_nlink);
- ip->i_uid = le32_to_cpu(dip->di_uid);
- ip->i_gid = le32_to_cpu(dip->di_gid);
+
+ uid = le32_to_cpu(dip->di_uid);
+ gid = le32_to_cpu(dip->di_gid);
+ ip->i_uid = INOXID_UID(XID_TAG(ip), uid, gid);
+ ip->i_gid = INOXID_GID(XID_TAG(ip), uid, gid);
+ ip->i_xid = INOXID_XID(XID_TAG(ip), uid, gid, 0);
+
ip->i_size = le64_to_cpu(dip->di_size);
ip->i_atime.tv_sec = le32_to_cpu(dip->di_atime.tv_sec);
ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
static void copy_to_dinode(struct dinode * dip, struct inode *ip)
{
struct jfs_inode_info *jfs_ip = JFS_IP(ip);
+ uid_t uid;
+ gid_t gid;
dip->di_fileset = cpu_to_le32(jfs_ip->fileset);
dip->di_inostamp = cpu_to_le32(JFS_SBI(ip->i_sb)->inostamp);
dip->di_size = cpu_to_le64(ip->i_size);
dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
dip->di_nlink = cpu_to_le32(ip->i_nlink);
- dip->di_uid = cpu_to_le32(ip->i_uid);
- dip->di_gid = cpu_to_le32(ip->i_gid);
+
+ uid = XIDINO_UID(XID_TAG(ip), ip->i_uid, ip->i_xid);
+ gid = XIDINO_GID(XID_TAG(ip), ip->i_gid, ip->i_xid);
+ dip->di_uid = cpu_to_le32(uid);
+ dip->di_gid = cpu_to_le32(gid);
/*
* mode2 is only needed for storing the higher order bits.
* Trust i_mode for the lower order ones