From: Nathan Scott Date: Tue, 18 Mar 2003 05:44:53 +0000 (+0000) Subject: xfsprogs update - kernel/user sync up and Ethan's Mac partition code. X-Git-Tag: XFS-1_3_0pre1~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eae766ca8686b78ea4a75d533104b34e40ade520;p=thirdparty%2Fxfsprogs-dev.git xfsprogs update - kernel/user sync up and Ethan's Mac partition code. CONTRIBUTED: erbenson@alaska.net. Add configure : configure.in dpeendency, as Mandy suggests. --- diff --git a/Makefile b/Makefile index 28ba4ed6e..fa0db078a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. +# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License as @@ -60,7 +60,7 @@ else clean: # if configure hasn't run, nothing to clean endif -$(CONFIGURE): +$(CONFIGURE): configure.in autoconf ./configure \ --prefix=/ \ diff --git a/db/command.c b/db/command.c index 28486396c..3aaff1ead 100644 --- a/db/command.c +++ b/db/command.c @@ -64,8 +64,6 @@ cmdinfo_t *cmdtab; int ncmds; -static int cmd_compare(const void *a, const void *b); - static int cmd_compare(const void *a, const void *b) { diff --git a/debian/changelog b/debian/changelog index e22584c8e..6fde2d1f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -xfsprogs (2.4.0-1) unstable; urgency=low +xfsprogs (2.4.1-1) unstable; urgency=low * New upstream release * Note: unwritten extents are now enabled by default in mkfs.xfs. - -- Nathan Scott Thu, 6 Mar 2003 12:00:38 +1100 + -- Nathan Scott Tue, 18 Mar 2003 16:16:43 +1100 xfsprogs (2.3.11-1) unstable; urgency=low diff --git a/doc/CHANGES b/doc/CHANGES index 44791a401..8600ca6bc 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,12 @@ +xfsprogs-2.4.1 (18 March 2002) + - Fix error reporting when zeroing parts of the realtime + device in phase6 of xfs_repair. + - Add a mkfs.xfs check for Mac partitions before writing + to the device. + - Thanks to Ethan Benson for this. + - Minor fix to the xfs_bmap(8) man page. + - Sync up user/kernel source in libxfs and headers. + xfsprogs-2.4.0 (06 March 2002) - Enable unwritten extents by default in mkfs.xfs. - Add a command to xfs_db to enable unwritten extents. diff --git a/include/Makefile b/include/Makefile index 18929aaa2..4a650bea8 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. +# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License as @@ -38,9 +38,9 @@ HFILES = handle.h jdm.h libxfs.h libxlog.h swab.h xqm.h \ xfs_attr_sf.h xfs_bit.h xfs_bmap.h xfs_bmap_btree.h xfs_btree.h \ xfs_buf_item.h xfs_da_btree.h xfs_dfrag.h xfs_dinode.h \ xfs_dir.h xfs_dir2.h xfs_dir2_block.h xfs_dir2_data.h xfs_dir2_leaf.h \ - xfs_dir2_node.h xfs_dir2_sf.h xfs_dir_leaf.h xfs_dir_sf.h xfs_dqblk.h \ - xfs_dquot_item.h xfs_extfree_item.h xfs_fs.h xfs_ialloc.h \ - xfs_ialloc_btree.h xfs_imap.h xfs_inode.h xfs_inode_item.h xfs_inum.h \ + xfs_dir2_node.h xfs_dir2_sf.h xfs_dir_leaf.h xfs_dir_sf.h \ + xfs_extfree_item.h xfs_fs.h xfs_ialloc.h xfs_ialloc_btree.h \ + xfs_imap.h xfs_inode.h xfs_inode_item.h xfs_inum.h \ xfs_log.h xfs_log_priv.h xfs_log_recover.h xfs_mount.h xfs_quota.h \ xfs_rtalloc.h xfs_sb.h xfs_trans.h xfs_trans_space.h xfs_types.h diff --git a/include/libxfs.h b/include/libxfs.h index 874acafe7..9c379aefe 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include diff --git a/include/libxlog.h b/include/libxlog.h index bb9e71b3d..9a2736ae4 100644 --- a/include/libxlog.h +++ b/include/libxlog.h @@ -64,8 +64,6 @@ typedef struct log { #include #include #include -#include - /* * macros mapping kernel code to user code diff --git a/include/xfs_bmap.h b/include/xfs_bmap.h index cb0dc44fb..a41ea99c0 100644 --- a/include/xfs_bmap.h +++ b/include/xfs_bmap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -76,10 +76,6 @@ typedef struct xfs_bmap_free #define XFS_BMAPI_IGSTATE 0x200 /* Ignore state - */ /* combine contig. space */ #define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */ -#define XFS_BMAPI_DIRECT_IO 0x800 /* Flag from cxfs client, not used - * by xfs directly. Indicates alloc - * request is for direct I/O not - * extent conversion by server */ #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAPI_AFLAG) int xfs_bmapi_aflag(int w); diff --git a/include/xfs_dqblk.h b/include/xfs_dqblk.h deleted file mode 100644 index 40f6a4cd4..000000000 --- a/include/xfs_dqblk.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_DQBLK_H__ -#define __XFS_DQBLK_H__ - -/* - * The ondisk form of a dquot structure. - */ -#define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ -#define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ - -/* - * This is the main portion of the on-disk representation of quota - * information for a user. This is the q_core of the xfs_dquot_t that - * is kept in kernel memory. We pad this with some more expansion room - * to construct the on disk structure. - */ -typedef struct xfs_disk_dquot { -/*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ -/*8 */ u_int8_t d_version; /* dquot version */ -/*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ -/*32*/ xfs_dqid_t d_id; /* user,project,group id */ -/*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ -/*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ -/*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ -/*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ -/*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ -/*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ -/*32*/ __int32_t d_itimer; /* zero if within inode limits if not, - this is when we refuse service */ -/*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ -/*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ -/*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ -/*32*/ __int32_t d_pad0; /* 64 bit align */ -/*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ -/*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ -/*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ -/*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ -/*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ -/*16*/ __uint16_t d_pad; -} xfs_disk_dquot_t; - -/* - * This is what goes on disk. This is separated from the xfs_disk_dquot because - * carrying the unnecessary padding would be a waste of memory. - */ -typedef struct xfs_dqblk { - xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ - char dd_fill[32]; /* filling for posterity */ -} xfs_dqblk_t; - -/* - * flags for q_flags field in the dquot. - */ -#define XFS_DQ_USER 0x0001 /* a user quota */ -/* #define XFS_DQ_PROJ 0x0002 -- project quota (IRIX) */ -#define XFS_DQ_GROUP 0x0004 /* a group quota */ -#define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ -#define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ -#define XFS_DQ_WANT 0x0020 /* for lookup/reclaim race */ -#define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ -#define XFS_DQ_MARKER 0x0080 /* sentinel */ - -/* - * In the worst case, when both user and group quotas are on, - * we can have a max of three dquots changing in a single transaction. - */ -#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) - -#endif /* __XFS_DQBLK_H__ */ diff --git a/include/xfs_dquot_item.h b/include/xfs_dquot_item.h deleted file mode 100644 index a11987e5e..000000000 --- a/include/xfs_dquot_item.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ - */ -#ifndef __XFS_DQUOT_ITEM_H__ -#define __XFS_DQUOT_ITEM_H__ - -/* - * These are the structures used to lay out dquots and quotaoff - * records on the log. Quite similar to those of inodes. - */ - -/* - * log format struct for dquots. - * The first two fields must be the type and size fitting into - * 32 bits : log_recovery code assumes that. - */ -typedef struct xfs_dq_logformat { - __uint16_t qlf_type; /* dquot log item type */ - __uint16_t qlf_size; /* size of this item */ - xfs_dqid_t qlf_id; /* usr/grp id number : 32 bits */ - __int64_t qlf_blkno; /* blkno of dquot buffer */ - __int32_t qlf_len; /* len of dquot buffer */ - __uint32_t qlf_boffset; /* off of dquot in buffer */ -} xfs_dq_logformat_t; - -/* - * log format struct for QUOTAOFF records. - * The first two fields must be the type and size fitting into - * 32 bits : log_recovery code assumes that. - * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer - * to the first and ensures that the first logitem is taken out of the AIL - * only when the last one is securely committed. - */ -typedef struct xfs_qoff_logformat { - unsigned short qf_type; /* quotaoff log item type */ - unsigned short qf_size; /* size of this item */ - unsigned int qf_flags; /* USR and/or GRP */ - char qf_pad[12]; /* padding for future */ -} xfs_qoff_logformat_t; - - -#ifdef __KERNEL__ - -struct xfs_dquot; -struct xfs_trans; -struct xfs_mount; -typedef struct xfs_dq_logitem { - xfs_log_item_t qli_item; /* common portion */ - struct xfs_dquot *qli_dquot; /* dquot ptr */ - xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ - unsigned short qli_pushbuf_flag; /* one bit used in push_ail */ -#ifdef DEBUG - uint64_t qli_push_owner; -#endif - xfs_dq_logformat_t qli_format; /* logged structure */ -} xfs_dq_logitem_t; - - -typedef struct xfs_qoff_logitem { - xfs_log_item_t qql_item; /* common portion */ - struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ - xfs_qoff_logformat_t qql_format; /* logged structure */ -} xfs_qoff_logitem_t; - - -extern void xfs_qm_dquot_logitem_init(struct xfs_dquot *); -extern xfs_qoff_logitem_t *xfs_qm_qoff_logitem_init(struct xfs_mount *, - xfs_qoff_logitem_t *, uint); -extern xfs_qoff_logitem_t *xfs_trans_get_qoff_item(struct xfs_trans *, - xfs_qoff_logitem_t *, uint); -extern void xfs_trans_log_quotaoff_item(struct xfs_trans *, - xfs_qoff_logitem_t *); - -#endif /* __KERNEL__ */ - -#endif /* __XFS_DQUOT_ITEM_H__ */ diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 046278e25..d6f56297d 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -154,11 +154,7 @@ typedef struct xfs_iocore { * Flags in the flags field */ -#define XFS_IOCORE_ISXFS 0x01 -#define XFS_IOCORE_ISCXFS 0x02 -#define XFS_IOCORE_RT 0x04 - -#define IO_IS_XFS(io) ((io)->io_flags & XFS_IOCORE_ISXFS) +#define XFS_IOCORE_RT 0x1 /* * xfs_iocore prototypes diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 27c53f7a0..924b61fbe 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -75,7 +75,6 @@ struct xfs_ihash; struct xfs_chash; struct xfs_inode; struct xfs_perag; -struct xfs_quotainfo; struct xfs_iocore; struct xfs_bmbt_irec; struct xfs_bmap_free; @@ -87,15 +86,120 @@ struct xfs_bmap_free; #define AIL_LOCK(mp,s) s=mutex_spinlock(&(mp)->m_ail_lock) #define AIL_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_ail_lock, s) + +/* + * Prototypes and functions for the Data Migration subsystem. + */ + +typedef int (*xfs_send_data_t)(int, struct bhv_desc *, + xfs_off_t, size_t, int, vrwlock_t *); +typedef int (*xfs_send_mmap_t)(struct vm_area_struct *, uint); +typedef int (*xfs_send_destroy_t)(struct bhv_desc *, dm_right_t); +typedef int (*xfs_send_namesp_t)(dm_eventtype_t, struct bhv_desc *, + dm_right_t, struct bhv_desc *, dm_right_t, + char *, char *, mode_t, int, int); +typedef void (*xfs_send_unmount_t)(struct vfs *, struct vnode *, + dm_right_t, mode_t, int, int); + +typedef struct xfs_dmops { + xfs_send_data_t xfs_send_data; + xfs_send_mmap_t xfs_send_mmap; + xfs_send_destroy_t xfs_send_destroy; + xfs_send_namesp_t xfs_send_namesp; + xfs_send_unmount_t xfs_send_unmount; +} xfs_dmops_t; + +#define XFS_SEND_DATA(mp, ev,bdp,off,len,fl,lock) \ + (*(mp)->m_dm_ops.xfs_send_data)(ev,bdp,off,len,fl,lock) +#define XFS_SEND_MMAP(mp, vma,fl) \ + (*(mp)->m_dm_ops.xfs_send_mmap)(vma,fl) +#define XFS_SEND_DESTROY(mp, bdp,right) \ + (*(mp)->m_dm_ops.xfs_send_destroy)(bdp,right) +#define XFS_SEND_NAMESP(mp, ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) \ + (*(mp)->m_dm_ops.xfs_send_namesp)(ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) +#define XFS_SEND_UNMOUNT(mp, vfsp,vp,right,mode,rval,fl) \ + (*(mp)->m_dm_ops.xfs_send_unmount)(vfsp,vp,right,mode,rval,fl) + + +/* + * Prototypes and functions for the Quota Management subsystem. + */ + +struct xfs_dquot; +struct xfs_dqtrxops; +struct xfs_quotainfo; + +typedef int (*xfs_qminit_t)(struct xfs_mount *, uint *, uint *); +typedef int (*xfs_qmmount_t)(struct xfs_mount *, uint, uint); +typedef int (*xfs_qmunmount_t)(struct xfs_mount *); +typedef void (*xfs_qmdone_t)(struct xfs_mount *); +typedef void (*xfs_dqrele_t)(struct xfs_dquot *); +typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint); +typedef void (*xfs_dqdetach_t)(struct xfs_inode *); +typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint); +typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *, + struct xfs_inode *, uid_t, gid_t, uint, + struct xfs_dquot **, struct xfs_dquot **); +typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *, + struct xfs_dquot *, struct xfs_dquot *); +typedef int (*xfs_dqvoprename_t)(struct xfs_inode **); +typedef struct xfs_dquot * (*xfs_dqvopchown_t)( + struct xfs_trans *, struct xfs_inode *, + struct xfs_dquot **, struct xfs_dquot *); +typedef int (*xfs_dqvopchownresv_t)(struct xfs_trans *, struct xfs_inode *, + struct xfs_dquot *, struct xfs_dquot *, uint); + +typedef struct xfs_qmops { + xfs_qminit_t xfs_qminit; + xfs_qmdone_t xfs_qmdone; + xfs_qmmount_t xfs_qmmount; + xfs_qmunmount_t xfs_qmunmount; + xfs_dqrele_t xfs_dqrele; + xfs_dqattach_t xfs_dqattach; + xfs_dqdetach_t xfs_dqdetach; + xfs_dqpurgeall_t xfs_dqpurgeall; + xfs_dqvopalloc_t xfs_dqvopalloc; + xfs_dqvopcreate_t xfs_dqvopcreate; + xfs_dqvoprename_t xfs_dqvoprename; + xfs_dqvopchown_t xfs_dqvopchown; + xfs_dqvopchownresv_t xfs_dqvopchownresv; + struct xfs_dqtrxops *xfs_dqtrxops; +} xfs_qmops_t; + +#define XFS_QM_INIT(mp, mnt, fl) \ + (*(mp)->m_qm_ops.xfs_qminit)(mp, mnt, fl) +#define XFS_QM_MOUNT(mp, mnt, fl) \ + (*(mp)->m_qm_ops.xfs_qmmount)(mp, mnt, fl) +#define XFS_QM_UNMOUNT(mp) \ + (*(mp)->m_qm_ops.xfs_qmunmount)(mp) +#define XFS_QM_DONE(mp) \ + (*(mp)->m_qm_ops.xfs_qmdone)(mp) +#define XFS_QM_DQRELE(mp, dq) \ + (*(mp)->m_qm_ops.xfs_dqrele)(dq) +#define XFS_QM_DQATTACH(mp, ip, fl) \ + (*(mp)->m_qm_ops.xfs_dqattach)(ip, fl) +#define XFS_QM_DQDETACH(mp, ip) \ + (*(mp)->m_qm_ops.xfs_dqdetach)(ip) +#define XFS_QM_DQPURGEALL(mp, fl) \ + (*(mp)->m_qm_ops.xfs_dqpurgeall)(mp, fl) +#define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, fl, dq1, dq2) \ + (*(mp)->m_qm_ops.xfs_dqvopalloc)(mp, ip, uid, gid, fl, dq1, dq2) +#define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \ + (*(mp)->m_qm_ops.xfs_dqvopcreate)(tp, ip, dq1, dq2) +#define XFS_QM_DQVOPRENAME(mp, ip) \ + (*(mp)->m_qm_ops.xfs_dqvoprename)(ip) +#define XFS_QM_DQVOPCHOWN(mp, tp, ip, dqp, dq) \ + (*(mp)->m_qm_ops.xfs_dqvopchown)(tp, ip, dqp, dq) +#define XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, dq1, dq2, fl) \ + (*(mp)->m_qm_ops.xfs_dqvopchownresv)(tp, ip, dq1, dq2, fl) + + /* * Prototypes and functions for I/O core modularization. */ -struct flid; -struct buf; - typedef int (*xfs_ioinit_t)(struct vfs *, - struct xfs_mount_args *, int *); + struct xfs_mount_args *, int); typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *, xfs_fileoff_t, xfs_filblks_t, int, xfs_fsblock_t *, xfs_extlen_t, @@ -137,61 +241,42 @@ typedef struct xfs_ioops { xfs_iodone_t xfs_iodone; } xfs_ioops_t; - #define XFS_IOINIT(vfsp, args, flags) \ (*(mp)->m_io_ops.xfs_ioinit)(vfsp, args, flags) - #define XFS_BMAPI(mp, trans,io,bno,len,f,first,tot,mval,nmap,flist) \ (*(mp)->m_io_ops.xfs_bmapi_func) \ (trans,(io)->io_obj,bno,len,f,first,tot,mval,nmap,flist) - #define XFS_BMAP_EOF(mp, io, endoff, whichfork, eof) \ (*(mp)->m_io_ops.xfs_bmap_eof_func) \ ((io)->io_obj, endoff, whichfork, eof) - #define XFS_IOMAP_WRITE_DIRECT(mp, io, offset, count, flags, mval, nmap, found)\ (*(mp)->m_io_ops.xfs_iomap_write_direct) \ ((io)->io_obj, offset, count, flags, mval, nmap, found) - #define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \ (*(mp)->m_io_ops.xfs_iomap_write_delay) \ ((io)->io_obj, offset, count, flags, mval, nmap) - #define XFS_IOMAP_WRITE_ALLOCATE(mp, io, mval, nmap) \ (*(mp)->m_io_ops.xfs_iomap_write_allocate) \ ((io)->io_obj, mval, nmap) - #define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \ (*(mp)->m_io_ops.xfs_iomap_write_unwritten) \ ((io)->io_obj, offset, count) - #define XFS_LCK_MAP_SHARED(mp, io) \ (*(mp)->m_io_ops.xfs_lck_map_shared)((io)->io_obj) - #define XFS_ILOCK(mp, io, mode) \ (*(mp)->m_io_ops.xfs_ilock)((io)->io_obj, mode) - #define XFS_ILOCK_NOWAIT(mp, io, mode) \ (*(mp)->m_io_ops.xfs_ilock_nowait)((io)->io_obj, mode) - #define XFS_IUNLOCK(mp, io, mode) \ (*(mp)->m_io_ops.xfs_unlock)((io)->io_obj, mode) - #define XFS_ILOCK_DEMOTE(mp, io, mode) \ (*(mp)->m_io_ops.xfs_ilock_demote)((io)->io_obj, mode) - #define XFS_SIZE(mp, io) \ (*(mp)->m_io_ops.xfs_size_func)((io)->io_obj) - #define XFS_IODONE(vfsp) \ (*(mp)->m_io_ops.xfs_iodone)(vfsp) -/* - * Prototypes and functions for the XFS realtime subsystem. - */ - - typedef struct xfs_mount { bhv_desc_t m_bhv; /* vfs xfs behavior */ xfs_tid_t m_tid; /* next unused tid for fs */ @@ -229,6 +314,8 @@ typedef struct xfs_mount { xfs_buftarg_t *m_logdev_targp;/* ptr to log device */ xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */ #define m_dev m_ddev_targp->pbr_dev +#define m_logdev m_logdev_targp->pbr_dev +#define m_rtdev m_rtdev_targp->pbr_dev __uint8_t m_dircook_elog; /* log d-cookie entry bits */ __uint8_t m_blkbit_log; /* blocklog + NBBY */ __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ @@ -289,13 +376,9 @@ typedef struct xfs_mount { int m_chsize; /* size of next field */ struct xfs_chash *m_chash; /* fs private inode per-cluster * hash table */ + struct xfs_dmops m_dm_ops; /* vector of DMI ops */ + struct xfs_qmops m_qm_ops; /* vector of XQM ops */ struct xfs_ioops m_io_ops; /* vector of I/O ops */ - struct xfs_expinfo *m_expinfo; /* info to export to other - cells. */ - uint64_t m_shadow_pinmask; - /* which bits matter in rpc - log item pin masks */ - uint m_cxfstype; /* mounted shared, etc. */ lock_t m_freeze_lock; /* Lock for m_frozen */ uint m_frozen; /* FS frozen for shutdown or * snapshot */ @@ -326,8 +409,7 @@ typedef struct xfs_mount { #define XFS_MOUNT_NOALIGN 0x00000080 /* turn off stripe alignment allocations */ /* 0x00000100 -- currently unused */ -#define XFS_MOUNT_REGISTERED 0x00000200 /* registered with cxfs master - cell logic */ + /* 0x00000200 -- currently unused */ #define XFS_MOUNT_NORECOVERY 0x00000400 /* no recovery - dirty fs */ #define XFS_MOUNT_SHARED 0x00000800 /* shared mount */ #define XFS_MOUNT_DFLT_IOSIZE 0x00001000 /* set default i/o size */ @@ -338,14 +420,6 @@ typedef struct xfs_mount { * 32 bits in size */ #define XFS_MOUNT_NOLOGFLUSH 0x00010000 -/* - * Flags for m_cxfstype - */ -#define XFS_CXFS_NOT 0x00000001 /* local mount */ -#define XFS_CXFS_SERVER 0x00000002 /* we're the CXFS server */ -#define XFS_CXFS_CLIENT 0x00000004 /* We're a CXFS client */ -#define XFS_CXFS_REC_ENABLED 0x00000008 /* recovery is enabled */ - #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) /* @@ -372,15 +446,17 @@ typedef struct xfs_mount { #define XFS_WSYNC_READIO_LOG 15 /* 32K */ #define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */ -#define xfs_force_shutdown(m,f) VFS_FORCE_SHUTDOWN(XFS_MTOVFS(m),f) +#define xfs_force_shutdown(m,f) \ + VFS_FORCE_SHUTDOWN((XFS_MTOVFS(m)), f, __FILE__, __LINE__) + /* * Flags sent to xfs_force_shutdown. */ #define XFS_METADATA_IO_ERROR 0x1 #define XFS_LOG_IO_ERROR 0x2 #define XFS_FORCE_UMOUNT 0x4 -#define XFS_CORRUPT_INCORE 0x8 /* corrupt in-memory data structures */ -#define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* shutdown came from remote cell */ +#define XFS_CORRUPT_INCORE 0x8 /* Corrupt in-memory data structures */ +#define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */ /* * xflags for xfs_syncsub @@ -390,9 +466,7 @@ typedef struct xfs_mount { /* * Flags for xfs_mountfs */ -#define XFS_MFSI_SECOND 0x01 /* Is a cxfs secondary mount -- skip */ - /* stuff which should only be done */ - /* once. */ +#define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */ #define XFS_MFSI_CLIENT 0x02 /* Is a client -- skip lots of stuff */ #define XFS_MFSI_NOUNLINK 0x08 /* Skip unlinked inode processing in */ /* log recovery */ @@ -412,6 +486,13 @@ xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp); #else #define XFS_BHVTOM(bdp) ((xfs_mount_t *)BHV_PDATA(bdp)) #endif +#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_VFSTOM) +xfs_mount_t *xfs_vfstom(vfs_t *vfs); +#define XFS_VFSTOM(vfs) xfs_vfstom(vfs) +#else +#define XFS_VFSTOM(vfs) \ + (XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops))) +#endif /* @@ -449,7 +530,7 @@ static inline xfs_agblock_t XFS_DADDR_TO_AGBNO(xfs_mount_t *mp, xfs_daddr_t d) */ typedef struct xfs_mod_sb { xfs_sb_field_t msb_field; /* Field to modify, see below */ - int msb_delta; /* change to make to the specified field */ + int msb_delta; /* Change to make to specified field */ } xfs_mod_sb_t; #define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock), PINOD) @@ -457,24 +538,27 @@ typedef struct xfs_mod_sb { #define XFS_SB_LOCK(mp) mutex_spinlock(&(mp)->m_sb_lock) #define XFS_SB_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_sb_lock,(s)) -void xfs_mod_sb(xfs_trans_t *, __int64_t); -xfs_mount_t *xfs_mount_init(void); -void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); -int xfs_mountfs(struct vfs *, xfs_mount_t *mp, dev_t, int); - -int xfs_unmountfs(xfs_mount_t *, struct cred *); -void xfs_unmountfs_close(xfs_mount_t *, struct cred *); -int xfs_unmountfs_writesb(xfs_mount_t *); -int xfs_unmount_flush(xfs_mount_t *, int); -int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int); -int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, uint, int); -int xfs_readsb(xfs_mount_t *mp); -struct xfs_buf *xfs_getsb(xfs_mount_t *, int); -void xfs_freesb(xfs_mount_t *); -void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); -int xfs_syncsub(xfs_mount_t *, int, int, int *); -void xfs_initialize_perag(xfs_mount_t *, int); -void xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t, __int64_t); +extern xfs_mount_t *xfs_mount_init(void); +extern void xfs_mod_sb(xfs_trans_t *, __int64_t); +extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); +extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, dev_t, int); + +extern int xfs_unmountfs(xfs_mount_t *, struct cred *); +extern void xfs_uuid_unmount(xfs_mount_t *mp); +extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); +extern int xfs_unmountfs_writesb(xfs_mount_t *); +extern int xfs_unmount_flush(xfs_mount_t *, int); +extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int); +extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, + uint, int); +extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); +extern int xfs_readsb(xfs_mount_t *mp); +extern void xfs_freesb(xfs_mount_t *); +extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); +extern int xfs_syncsub(xfs_mount_t *, int, int, int *); +extern void xfs_initialize_perag(xfs_mount_t *, int); +extern void xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t, + __int64_t); /* * Flags for freeze operations. @@ -482,11 +566,19 @@ void xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t, __int64_t); #define XFS_FREEZE_WRITE 1 #define XFS_FREEZE_TRANS 2 -void xfs_start_freeze(xfs_mount_t *, int); -void xfs_finish_freeze(xfs_mount_t *); -void xfs_check_frozen(xfs_mount_t *, bhv_desc_t *, int); +extern void xfs_start_freeze(xfs_mount_t *, int); +extern void xfs_finish_freeze(xfs_mount_t *); +extern void xfs_check_frozen(xfs_mount_t *, bhv_desc_t *, int); + +extern struct vfsops xfs_vfsops; +extern struct vnodeops xfs_vnodeops; + +extern struct xfs_dmops xfs_dmcore_xfs; +extern struct xfs_qmops xfs_qmcore_xfs; +extern struct xfs_ioops xfs_iocore_xfs; -extern struct vfsops xfs_vfsops; +extern int xfs_init(void); +extern void xfs_cleanup(void); #endif /* __KERNEL__ */ diff --git a/include/xfs_quota.h b/include/xfs_quota.h index 37639212e..57c2bb304 100644 --- a/include/xfs_quota.h +++ b/include/xfs_quota.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -32,6 +32,12 @@ #ifndef __XFS_QUOTA_H__ #define __XFS_QUOTA_H__ +/* + * The ondisk form of a dquot structure. + */ +#define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ +#define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ + /* * uid_t and gid_t are hard-coded to 32 bits in the inode. * Hence, an 'id' in a dquot is 32 bits.. @@ -46,6 +52,100 @@ typedef __int32_t xfs_dqid_t; typedef __uint64_t xfs_qcnt_t; typedef __uint16_t xfs_qwarncnt_t; +/* + * This is the main portion of the on-disk representation of quota + * information for a user. This is the q_core of the xfs_dquot_t that + * is kept in kernel memory. We pad this with some more expansion room + * to construct the on disk structure. + */ +typedef struct xfs_disk_dquot { +/*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ +/*8 */ u_int8_t d_version; /* dquot version */ +/*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ +/*32*/ xfs_dqid_t d_id; /* user,project,group id */ +/*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ +/*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ +/*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ +/*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ +/*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ +/*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ +/*32*/ __int32_t d_itimer; /* zero if within inode limits if not, + this is when we refuse service */ +/*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ +/*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ +/*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ +/*32*/ __int32_t d_pad0; /* 64 bit align */ +/*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ +/*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ +/*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ +/*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ +/*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ +/*16*/ __uint16_t d_pad; +} xfs_disk_dquot_t; + +/* + * This is what goes on disk. This is separated from the xfs_disk_dquot because + * carrying the unnecessary padding would be a waste of memory. + */ +typedef struct xfs_dqblk { + xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ + char dd_fill[32]; /* filling for posterity */ +} xfs_dqblk_t; + +/* + * flags for q_flags field in the dquot. + */ +#define XFS_DQ_USER 0x0001 /* a user quota */ +/* #define XFS_DQ_PROJ 0x0002 -- project quota (IRIX) */ +#define XFS_DQ_GROUP 0x0004 /* a group quota */ +#define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ +#define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ +#define XFS_DQ_WANT 0x0020 /* for lookup/reclaim race */ +#define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ +#define XFS_DQ_MARKER 0x0080 /* sentinel */ + +/* + * In the worst case, when both user and group quotas are on, + * we can have a max of three dquots changing in a single transaction. + */ +#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) + + +/* + * These are the structures used to lay out dquots and quotaoff + * records on the log. Quite similar to those of inodes. + */ + +/* + * log format struct for dquots. + * The first two fields must be the type and size fitting into + * 32 bits : log_recovery code assumes that. + */ +typedef struct xfs_dq_logformat { + __uint16_t qlf_type; /* dquot log item type */ + __uint16_t qlf_size; /* size of this item */ + xfs_dqid_t qlf_id; /* usr/grp id number : 32 bits */ + __int64_t qlf_blkno; /* blkno of dquot buffer */ + __int32_t qlf_len; /* len of dquot buffer */ + __uint32_t qlf_boffset; /* off of dquot in buffer */ +} xfs_dq_logformat_t; + +/* + * log format struct for QUOTAOFF records. + * The first two fields must be the type and size fitting into + * 32 bits : log_recovery code assumes that. + * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer + * to the first and ensures that the first logitem is taken out of the AIL + * only when the last one is securely committed. + */ +typedef struct xfs_qoff_logformat { + unsigned short qf_type; /* quotaoff log item type */ + unsigned short qf_size; /* size of this item */ + unsigned int qf_flags; /* USR and/or GRP */ + char qf_pad[12]; /* padding for future */ +} xfs_qoff_logformat_t; + + /* * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. */ @@ -134,13 +234,14 @@ typedef __uint16_t xfs_qwarncnt_t; #define XFS_QMOPT_QUOTALL (XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA) #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) +#ifdef __KERNEL__ /* * This check is done typically without holding the inode lock; * that may seem racey, but it is harmless in the context that it is used. * The inode cannot go inactive as long a reference is kept, and * therefore if dquot(s) were attached, they'll stay consistent. * If, for example, the ownership of the inode changes while - * we didnt have the inode locked, the appropriate dquot(s) will be + * we didn't have the inode locked, the appropriate dquot(s) will be * attached atomically. */ #define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ @@ -161,190 +262,93 @@ typedef __uint16_t xfs_qwarncnt_t; #define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ XFS_GQUOTA_ACTIVE) -#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) - - -#ifdef __KERNEL__ - -#ifdef CONFIG_XFS_QUOTA -/* - * External Interface to the XFS disk quota subsystem. - */ -struct xfs_disk_dquot; -struct xfs_dqhash; -struct xfs_dquot; -struct xfs_inode; -struct xfs_mount; -struct xfs_trans; - -/* - * Quota Manager Interface. - */ -extern struct xfs_qm *xfs_qm_init(void); -extern void xfs_qm_destroy(struct xfs_qm *); -extern int xfs_qm_dqflush_all(struct xfs_mount *, int); -extern int xfs_qm_dqattach(struct xfs_inode *, uint); -extern int xfs_qm_dqpurge_all(struct xfs_mount *, uint); -extern void xfs_qm_mount_quotainit(struct xfs_mount *, uint); -extern void xfs_qm_unmount_quotadestroy(struct xfs_mount *); -extern int xfs_qm_mount_quotas(struct xfs_mount *); -extern int xfs_qm_unmount_quotas(struct xfs_mount *); -extern void xfs_qm_dqdettach_inode(struct xfs_inode *); -extern int xfs_qm_sync(struct xfs_mount *, short); /* - * Dquot interface. + * The structure kept inside the xfs_trans_t keep track of dquot changes + * within a transaction and apply them later. */ -extern void xfs_dqlock(struct xfs_dquot *); -extern void xfs_dqunlock(struct xfs_dquot *); -extern void xfs_dqunlock_nonotify(struct xfs_dquot *); -extern void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); -extern void xfs_qm_dqput(struct xfs_dquot *); -extern void xfs_qm_dqrele(struct xfs_dquot *); -extern xfs_dqid_t xfs_qm_dqid(struct xfs_dquot *); -extern int xfs_qm_dqget(struct xfs_mount *, - struct xfs_inode *, xfs_dqid_t, - uint, uint, struct xfs_dquot **); -extern int xfs_qm_dqcheck(struct xfs_disk_dquot *, - xfs_dqid_t, uint, uint, char *); +typedef struct xfs_dqtrx { + struct xfs_dquot *qt_dquot; /* the dquot this refers to */ + ulong qt_blk_res; /* blks reserved on a dquot */ + ulong qt_blk_res_used; /* blks used from the reservation */ + ulong qt_ino_res; /* inode reserved on a dquot */ + ulong qt_ino_res_used; /* inodes used from the reservation */ + long qt_bcount_delta; /* dquot blk count changes */ + long qt_delbcnt_delta; /* delayed dquot blk count changes */ + long qt_icount_delta; /* dquot inode count changes */ + ulong qt_rtblk_res; /* # blks reserved on a dquot */ + ulong qt_rtblk_res_used;/* # blks used from reservation */ + long qt_rtbcount_delta;/* dquot realtime blk changes */ + long qt_delrtb_delta; /* delayed RT blk count changes */ +} xfs_dqtrx_t; /* - * Vnodeops specific code that should actually be _in_ xfs_vnodeops.c, but - * is here because it's nicer to keep vnodeops (therefore, XFS) lean - * and clean. + * Dquot transaction functions, used if quota is enabled. */ -extern struct xfs_dquot * xfs_qm_vop_chown(struct xfs_trans *, - struct xfs_inode *, - struct xfs_dquot **, - struct xfs_dquot *); -extern int xfs_qm_vop_dqalloc(struct xfs_mount *, - struct xfs_inode *, - uid_t, gid_t, uint, - struct xfs_dquot **, - struct xfs_dquot **); - -extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, - struct xfs_inode *, - struct xfs_dquot *, - struct xfs_dquot *, - uint); - -extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); -extern void xfs_qm_vop_dqattach_and_dqmod_newinode( - struct xfs_trans *, - struct xfs_inode *, - struct xfs_dquot *, - struct xfs_dquot *); - - -/* - * Dquot Transaction interface - */ -extern void xfs_trans_alloc_dqinfo(struct xfs_trans *); -extern void xfs_trans_free_dqinfo(struct xfs_trans *); -extern void xfs_trans_dup_dqinfo(struct xfs_trans *, - struct xfs_trans *); -extern void xfs_trans_mod_dquot(struct xfs_trans *, - struct xfs_dquot *, - uint, long); -extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, - struct xfs_inode *, - uint, long); -extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); -extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); - -extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, - struct xfs_inode *, - long, long, uint); - - -extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, - struct xfs_dquot *, - struct xfs_dquot *, - long, long, uint); -extern void xfs_trans_log_dquot(struct xfs_trans *, - struct xfs_dquot *); -extern void xfs_trans_dqjoin(struct xfs_trans *, - struct xfs_dquot *); -extern void xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint); - -# define _XQM_ZONE_DESTROY(z) ((z)? kmem_cache_destroy(z) : (void)0) - -#else -# define xfs_qm_init() (NULL) -# define xfs_qm_destroy(xqm) do { } while (0) -# define xfs_qm_dqflush_all(m,t) (ENOSYS) -# define xfs_qm_dqattach(i,t) (ENOSYS) -# define xfs_qm_dqpurge_all(m,t) (ENOSYS) -# define xfs_qm_mount_quotainit(m,t) do { } while (0) -# define xfs_qm_unmount_quotadestroy(m) do { } while (0) -# define xfs_qm_mount_quotas(m) (ENOSYS) -# define xfs_qm_unmount_quotas(m) (ENOSYS) -# define xfs_qm_dqdettach_inode(i) do { } while (0) -# define xfs_qm_sync(m,t) (ENOSYS) -# define xfs_dqlock(d) do { } while (0) -# define xfs_dqunlock(d) do { } while (0) -# define xfs_dqunlock_nonotify(d) do { } while (0) -# define xfs_dqlock2(d1,d2) do { } while (0) -# define xfs_qm_dqput(d) do { } while (0) -# define xfs_qm_dqrele(d) do { } while (0) -# define xfs_qm_dqid(d) (-1) -# define xfs_qm_dqget(m,i,di,t,f,d) (ENOSYS) -# define xfs_qm_dqcheck(dd,di,t,f,s) (ENOSYS) -# define xfs_trans_alloc_dqinfo(t) do { } while (0) -# define xfs_trans_free_dqinfo(t) do { } while (0) -# define xfs_trans_dup_dqinfo(t1,t2) do { } while (0) -# define xfs_trans_mod_dquot(t,d,f,x) do { } while (0) -# define xfs_trans_mod_dquot_byino(t,i,f,x) do { } while (0) -# define xfs_trans_apply_dquot_deltas(t) do { } while (0) -# define xfs_trans_unreserve_and_mod_dquots(t) do { } while (0) -# define xfs_trans_reserve_quota_nblks(t,i,nb,ni,f) (ENOSYS) -# define xfs_trans_reserve_quota_bydquots(t,x,y,b,i,f) (ENOSYS) -# define xfs_trans_log_dquot(t,d) do { } while (0) -# define xfs_trans_dqjoin(t,d) do { } while (0) -# define xfs_qm_dqrele_all_inodes(m,t) do { } while (0) -# define xfs_qm_vop_chown(t,i,d1,d2) (NULL) -# define xfs_qm_vop_dqalloc(m,i,u,g,f,d1,d2) (ENOSYS) -# define xfs_qm_vop_chown_reserve(t,i,d1,d2,f) (ENOSYS) -# define xfs_qm_vop_rename_dqattach(i) (ENOSYS) -# define xfs_qm_vop_dqattach_and_dqmod_newinode(t,i,x,y) do { } while (0) -# define _XQM_ZONE_DESTROY(z) do { } while (0) -#endif /* CONFIG_XFS_QUOTA */ - -/* - * Regular disk block quota reservations - */ -#define xfs_trans_reserve_blkquota(tp, ip, nblks) \ -xfs_trans_reserve_quota_nblks(tp, ip, nblks, 0, XFS_QMOPT_RES_REGBLKS) - -#define xfs_trans_reserve_blkquota_force(tp, ip, nblks) \ -xfs_trans_reserve_quota_nblks(tp, ip, nblks, 0, \ - XFS_QMOPT_RES_REGBLKS|XFS_QMOPT_FORCE_RES) - -#define xfs_trans_unreserve_blkquota(tp, ip, nblks) \ -(void)xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), 0, XFS_QMOPT_RES_REGBLKS) - -#define xfs_trans_reserve_quota(tp, udq, gdq, nb, ni, f) \ -xfs_trans_reserve_quota_bydquots(tp, udq, gdq, nb, ni, f|XFS_QMOPT_RES_REGBLKS) - -#define xfs_trans_unreserve_quota(tp, ud, gd, b, i, f) \ -xfs_trans_reserve_quota_bydquots(tp, ud, gd, -(b), -(i), f|XFS_QMOPT_RES_REGBLKS) - -/* - * Realtime disk block quota reservations - */ -#define xfs_trans_reserve_rtblkquota(mp, tp, ip, nblks) \ -xfs_trans_reserve_quota_nblks(tp, ip, nblks, 0, XFS_QMOPT_RES_RTBLKS) - -#define xfs_trans_unreserve_rtblkquota(tp, ip, nblks) \ -(void)xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), 0, XFS_QMOPT_RES_RTBLKS) - -#define xfs_trans_reserve_rtquota(mp, tp, uq, pq, blks, f) \ -xfs_trans_reserve_quota_bydquots(mp, tp, uq, pq, blks, 0, f|XFS_QMOPT_RES_RTBLKS) - -#define xfs_trans_unreserve_rtquota(tp, uq, pq, blks) \ -xfs_trans_reserve_quota_bydquots(tp, uq, pq, -(blks), XFS_QMOPT_RES_RTBLKS) - +typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); +typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, + struct xfs_inode *, uint, long); +typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); +typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); +typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); +typedef int (*qo_reserve_quota_nblks_t)( + struct xfs_trans *, struct xfs_mount *, + struct xfs_inode *, long, long, uint); +typedef int (*qo_reserve_quota_bydquots_t)( + struct xfs_trans *, struct xfs_mount *, + struct xfs_dquot *, struct xfs_dquot *, + long, long, uint); +typedef struct xfs_dqtrxops { + qo_dup_dqinfo_t qo_dup_dqinfo; + qo_free_dqinfo_t qo_free_dqinfo; + qo_mod_dquot_byino_t qo_mod_dquot_byino; + qo_apply_dquot_deltas_t qo_apply_dquot_deltas; + qo_reserve_quota_nblks_t qo_reserve_quota_nblks; + qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; + qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; +} xfs_dqtrxops_t; + +#define XFS_DQTRXOP(mp, tp, op, args...) \ + ((mp)->m_qm_ops.xfs_dqtrxops ? \ + ((mp)->m_qm_ops.xfs_dqtrxops->op)(tp, ## args) : 0) + +#define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ + XFS_DQTRXOP(mp, otp, qo_dup_dqinfo, ntp) +#define XFS_TRANS_FREE_DQINFO(mp, tp) \ + XFS_DQTRXOP(mp, tp, qo_free_dqinfo) +#define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ + XFS_DQTRXOP(mp, tp, qo_mod_dquot_byino, ip, field, delta) +#define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ + XFS_DQTRXOP(mp, tp, qo_apply_dquot_deltas) +#define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ + XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) +#define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ + XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) +#define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ + XFS_DQTRXOP(mp, tp, qo_unreserve_and_mod_dquots) + +#define XFS_TRANS_RESERVE_BLKQUOTA(mp, tp, ip, nblks) \ + XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ + XFS_QMOPT_RES_REGBLKS) +#define XFS_TRANS_RESERVE_BLKQUOTA_FORCE(mp, tp, ip, nblks) \ + XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ + XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES) +#define XFS_TRANS_UNRESERVE_BLKQUOTA(mp, tp, ip, nblks) \ + XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), 0, \ + XFS_QMOPT_RES_REGBLKS) +#define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ + XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ + f | XFS_QMOPT_RES_REGBLKS) +#define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ + XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ + f | XFS_QMOPT_RES_REGBLKS) + +extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); + +extern struct bhv_vfsops xfs_qmops; + +extern void xfs_qm_init(void); +extern void xfs_qm_exit(void); #endif /* __KERNEL__ */ diff --git a/include/xfs_rtalloc.h b/include/xfs_rtalloc.h index 286436f82..19e704107 100644 --- a/include/xfs_rtalloc.h +++ b/include/xfs_rtalloc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -35,6 +35,8 @@ struct xfs_mount; struct xfs_trans; +#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) + /* Min and max rt extent sizes, specified in bytes */ #define XFS_MAX_RTEXTSIZE (1024 * 1024 * 1024) /* 1GB */ #define XFS_DFL_RTEXTSIZE (64 * 1024) /* 64KB */ diff --git a/include/xfs_trans.h b/include/xfs_trans.h index ed091cb1c..23264a5b9 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -64,7 +64,6 @@ typedef struct xfs_trans_header { #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */ #define XFS_LI_DQUOT 0x123d #define XFS_LI_QUOTAOFF 0x123e -#define XFS_LI_RPC 0x123f /* CXFS RPC return info */ /* * Transaction types. Used to distinguish types of buffers. @@ -1014,10 +1013,7 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, struct xfs_efd_log_item *, xfs_fsblock_t, xfs_extlen_t); -void xfs_trans_log_create_rpc(xfs_trans_t *, int, xfs_ino_t); -void xfs_trans_log_setattr_rpc(xfs_trans_t *, int); int xfs_trans_commit(xfs_trans_t *, uint flags, xfs_lsn_t *); -void xfs_trans_commit_async(struct xfs_mount *); void xfs_trans_cancel(xfs_trans_t *, int); void xfs_trans_ail_init(struct xfs_mount *); xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t); diff --git a/include/xfs_types.h b/include/xfs_types.h index 302f91ecf..6e9b5d88d 100644 --- a/include/xfs_types.h +++ b/include/xfs_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -34,8 +34,6 @@ #ifdef __KERNEL__ -#include - /* * POSIX Extensions */ @@ -56,9 +54,7 @@ typedef unsigned int __uint32_t; typedef signed long long int __int64_t; typedef unsigned long long int __uint64_t; -typedef enum { B_FALSE, B_TRUE } boolean_t; - - +typedef enum { B_FALSE,B_TRUE } boolean_t; typedef __int64_t prid_t; /* project ID */ typedef __uint32_t inst_t; /* an instruction */ @@ -68,12 +64,6 @@ typedef __s64 xfs_daddr_t; /* type */ typedef char * xfs_caddr_t; /* type */ typedef __u32 xfs_dev_t; -typedef struct timespec timespec_t; - -typedef struct { - unsigned char __u_bits[16]; -} uuid_t; - /* __psint_t is the same size as a pointer */ #if (BITS_PER_LONG == 32) typedef __int32_t __psint_t; @@ -100,8 +90,14 @@ typedef __uint64_t __psunsigned_t; * the limiting factor. */ -#ifndef XFS_BIG_FILESYSTEMS -#define XFS_BIG_FILESYSTEMS 0 +#if defined(CONFIG_LBD) || (defined(HAVE_SECTOR_T) && (BITS_PER_LONG == 64)) +# ifndef XFS_BIG_FILESYSTEMS +# define XFS_BIG_FILESYSTEMS 1 +# endif +#else +# ifndef XFS_BIG_FILESYSTEMS +# define XFS_BIG_FILESYSTEMS 0 +# endif #endif typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */ @@ -185,6 +181,18 @@ typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */ */ #define MAXNAMELEN 256 +typedef struct xfs_dirent { /* data from readdir() */ + xfs_ino_t d_ino; /* inode number of entry */ + xfs_off_t d_off; /* offset of disk directory entry */ + unsigned short d_reclen; /* length of this record */ + char d_name[1]; /* name of file */ +} xfs_dirent_t; + +#define DIRENTBASESIZE (((xfs_dirent_t *)0)->d_name - (char *)0) +#define DIRENTSIZE(namelen) \ + ((DIRENTBASESIZE + (namelen) + \ + sizeof(xfs_off_t)) & ~(sizeof(xfs_off_t) - 1)) + typedef enum { XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi } xfs_lookup_t; diff --git a/libdisk/pttype.c b/libdisk/pttype.c index 12ed223eb..f8351c135 100644 --- a/libdisk/pttype.c +++ b/libdisk/pttype.c @@ -93,6 +93,14 @@ sun_parttable(char *base) return !csum; } +static int +mac_parttable(char *base) +{ + return (ntohs(maclabel(base)->magic) == MAC_LABEL_MAGIC || + ntohs(maclabel(base)->magic) == MAC_PARTITION_MAGIC || + ntohs(maclabel(base)->magic) == MAC_OLD_PARTITION_MAGIC); +} + char * pttype(char *device) @@ -114,6 +122,8 @@ pttype(char *device) type = "AIX"; else if (dos_parttable(buf)) type = "DOS"; + else if (mac_parttable(buf)) + type = "Mac"; } if (fd >= 0) diff --git a/libdisk/pttype.h b/libdisk/pttype.h index 3193eba45..e7b32580b 100644 --- a/libdisk/pttype.h +++ b/libdisk/pttype.h @@ -39,3 +39,13 @@ typedef struct { #define AIX_LABEL_MAGIC 0xc9c2d4c1 #define AIX_LABEL_MAGIC_SWAPPED 0xc1d4c2c9 #define aixlabel(x) ((aix_partition *)x) + +typedef struct { + unsigned short magic; + /* ... */ +} mac_partition; + +#define MAC_LABEL_MAGIC 0x4552 +#define MAC_PARTITION_MAGIC 0x504d +#define MAC_OLD_PARTITION_MAGIC 0x5453 +#define maclabel(x) ((mac_partition *)x) diff --git a/libxfs/xfs.h b/libxfs/xfs.h index aabaa0a5f..eb8ed7840 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -272,6 +272,10 @@ typedef struct { dev_t dev; } xfs_buftarg_t; #define xfs_btree_reada_bufs(m,fsb,c,x) ((void) 0) #undef XFS_DIR_SHORTFORM_VALIDATE_ONDISK #define XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp,dip) 0 +#define XFS_TRANS_MOD_DQUOT_BYINO(mp,tp,ip,field,delta) +#define XFS_TRANS_RESERVE_BLKQUOTA(mp,tp,ip,nblks) 0 +#define XFS_TRANS_UNRESERVE_BLKQUOTA(mp,tp,ip,nblks) +#define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl) #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95)) # define xfs_fs_cmn_err(a,b,msg,args...)( fprintf(stderr, msg, ## args) ) diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 3485e4a06..ade4680a6 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -1678,7 +1678,7 @@ xfs_bmap_alloc( */ mp = ap->ip->i_mount; nullfb = ap->firstblock == NULLFSBLOCK; - rt = (ap->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && ap->userdata; + rt = XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata; fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock); #ifdef __KERNEL__ if (rt) { @@ -2000,14 +2000,10 @@ xfs_bmap_alloc( * Adjust the disk quota also. This was reserved * earlier. */ - if (XFS_IS_QUOTA_ON(mp) && - ap->ip->i_ino != mp->m_sb.sb_uquotino && - ap->ip->i_ino != mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(ap->tp, ap->ip, - ap->wasdel ? - XFS_TRANS_DQ_DELRTBCOUNT : + XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, + ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : XFS_TRANS_DQ_RTBCOUNT, - (long)ralen); + (long) ralen); } else ap->alen = 0; #endif /* __KERNEL__ */ @@ -2224,14 +2220,10 @@ xfs_bmap_alloc( * Adjust the disk quota also. This was reserved * earlier. */ - if (XFS_IS_QUOTA_ON(mp) && - ap->ip->i_ino != mp->m_sb.sb_uquotino && - ap->ip->i_ino != mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(ap->tp, ap->ip, - ap->wasdel ? - XFS_TRANS_DQ_DELBCOUNT : + XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, + ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT, - (long)args.len); + (long) args.len); } else { ap->rval = NULLFSBLOCK; ap->alen = 0; @@ -2288,10 +2280,7 @@ xfs_bmap_btree_to_extents( return error; xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); ip->i_d.di_nblocks--; - if (XFS_IS_QUOTA_ON(mp) && - ip->i_ino != mp->m_sb.sb_uquotino && - ip->i_ino != mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); + XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); xfs_trans_binval(tp, cbp); if (cur->bc_bufs[0] == cbp) cur->bc_bufs[0] = NULL; @@ -2387,10 +2376,7 @@ xfs_bmap_del_extent( goto done; do_fx = 0; nblks = len * mp->m_sb.sb_rextsize; - if (XFS_IS_QUOTA_ON(mp) && - ip->i_ino != mp->m_sb.sb_uquotino && - ip->i_ino != mp->m_sb.sb_gquotino) - qfield = XFS_TRANS_DQ_RTBCOUNT; + qfield = XFS_TRANS_DQ_RTBCOUNT; } /* * Ordinary allocation. @@ -2398,10 +2384,7 @@ xfs_bmap_del_extent( else { do_fx = 1; nblks = del->br_blockcount; - if (XFS_IS_QUOTA_ON(mp) && - ip->i_ino != mp->m_sb.sb_uquotino && - ip->i_ino != mp->m_sb.sb_gquotino) - qfield = XFS_TRANS_DQ_BCOUNT; + qfield = XFS_TRANS_DQ_BCOUNT; } /* * Set up del_endblock and cur for later. @@ -2621,7 +2604,8 @@ xfs_bmap_del_extent( * Adjust quota data. */ if (qfield) - xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); + XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, qfield, (long)-nblks); + /* * Account for change in delayed indirect blocks. * Nothing to do for disk quota accounting here. @@ -2772,10 +2756,7 @@ xfs_bmap_extents_to_btree( *firstblock = cur->bc_private.b.firstblock = args.fsbno; cur->bc_private.b.allocated++; ip->i_d.di_nblocks++; - if (XFS_IS_QUOTA_ON(mp) && - ip->i_ino != mp->m_sb.sb_uquotino && - ip->i_ino != mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); + XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); /* * Fill in the child block. @@ -2918,11 +2899,8 @@ xfs_bmap_local_to_extents( xfs_bmap_trace_post_update(fname, "new", ip, 0, whichfork); XFS_IFORK_NEXT_SET(ip, whichfork, 1); ip->i_d.di_nblocks = 1; - if (XFS_IS_QUOTA_ON(args.mp) && - ip->i_ino != args.mp->m_sb.sb_uquotino && - ip->i_ino != args.mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, - 1L); + XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, + XFS_TRANS_DQ_BCOUNT, 1L); flags |= XFS_ILOG_FEXT(whichfork); } else ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); @@ -3635,8 +3613,8 @@ xfs_bmapi( cur = NULL; if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { ASSERT(wr && tp); - if ((error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, - &logflags, whichfork))) + if ((error = xfs_bmap_local_to_extents(tp, ip, + firstblock, total, &logflags, whichfork))) goto error0; } if (wr && *firstblock == NULLFSBLOCK) { @@ -3710,9 +3688,8 @@ xfs_bmapi( * We return EDQUOT if we haven't allocated * blks already inside this loop; */ - if (XFS_IS_QUOTA_ON(ip->i_mount) && - xfs_trans_reserve_blkquota(NULL, ip, - (long)alen)) { + if (XFS_TRANS_RESERVE_BLKQUOTA( + mp, NULL, ip, (long)alen)) { if (n == 0) { *nmap = 0; ASSERT(cur == NULL); @@ -3720,12 +3697,10 @@ xfs_bmapi( } break; } - if (xfs_mod_incore_sb(ip->i_mount, - XFS_SBS_FDBLOCKS, + if (xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, -(alen + indlen), rsvd)) { - if (XFS_IS_QUOTA_ON(ip->i_mount)) - xfs_trans_unreserve_blkquota( - NULL, ip, (long)alen); + XFS_TRANS_UNRESERVE_BLKQUOTA( + mp, NULL, ip, (long)alen); break; } ip->i_delayed_blks += alen; @@ -3788,15 +3763,11 @@ xfs_bmapi( alen = bma.alen; aoff = bma.off; ASSERT(*firstblock == NULLFSBLOCK || - XFS_FSB_TO_AGNO(ip->i_mount, - *firstblock) == - XFS_FSB_TO_AGNO(ip->i_mount, - bma.firstblock) || + XFS_FSB_TO_AGNO(mp, *firstblock) == + XFS_FSB_TO_AGNO(mp, bma.firstblock) || (flist->xbf_low && - XFS_FSB_TO_AGNO(ip->i_mount, - *firstblock) < - XFS_FSB_TO_AGNO(ip->i_mount, - bma.firstblock))); + XFS_FSB_TO_AGNO(mp, *firstblock) < + XFS_FSB_TO_AGNO(mp, bma.firstblock))); *firstblock = bma.firstblock; if (cur) cur->bc_private.b.firstblock = @@ -3804,7 +3775,7 @@ xfs_bmapi( if (abno == NULLFSBLOCK) break; if ((ifp->if_flags & XFS_IFBROOT) && !cur) { - cur = xfs_btree_init_cursor(ip->i_mount, + cur = xfs_btree_init_cursor(mp, tp, NULL, 0, XFS_BTNUM_BMAP, ip, whichfork); cur->bc_private.b.firstblock = @@ -3921,7 +3892,7 @@ xfs_bmapi( */ ASSERT(mval->br_blockcount <= len); if ((ifp->if_flags & XFS_IFBROOT) && !cur) { - cur = xfs_btree_init_cursor(ip->i_mount, + cur = xfs_btree_init_cursor(mp, tp, NULL, 0, XFS_BTNUM_BMAP, ip, whichfork); cur->bc_private.b.firstblock = @@ -4043,12 +4014,12 @@ error0: if (cur) { if (!error) { ASSERT(*firstblock == NULLFSBLOCK || - XFS_FSB_TO_AGNO(ip->i_mount, *firstblock) == - XFS_FSB_TO_AGNO(ip->i_mount, + XFS_FSB_TO_AGNO(mp, *firstblock) == + XFS_FSB_TO_AGNO(mp, cur->bc_private.b.firstblock) || (flist->xbf_low && - XFS_FSB_TO_AGNO(ip->i_mount, *firstblock) < - XFS_FSB_TO_AGNO(ip->i_mount, + XFS_FSB_TO_AGNO(mp, *firstblock) < + XFS_FSB_TO_AGNO(mp, cur->bc_private.b.firstblock))); *firstblock = cur->bc_private.b.firstblock; } @@ -4358,16 +4329,11 @@ xfs_bunmapi( ASSERT(STARTBLOCKVAL(del.br_startblock) > 0); xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, (int)del.br_blockcount, rsvd); - if (XFS_IS_QUOTA_ON(ip->i_mount)) { - ASSERT(ip->i_ino != mp->m_sb.sb_uquotino); - ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); - if (!isrt) - xfs_trans_unreserve_blkquota(NULL, ip, - (long)del.br_blockcount); - else - xfs_trans_unreserve_rtblkquota(NULL, ip, - (long)del.br_blockcount); - } + /* Unreserve our quota space */ + XFS_TRANS_RESERVE_QUOTA_NBLKS( + mp, NULL, ip, -((long)del.br_blockcount), 0, + isrt ? XFS_QMOPT_RES_RTBLKS : + XFS_QMOPT_RES_REGBLKS); ip->i_delayed_blks -= del.br_blockcount; if (cur) cur->bc_private.b.flags |= diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 39c85c44b..dc38267d0 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as @@ -364,8 +364,8 @@ xfs_bmbt_delrec( xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, - INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rrbp, - XFS_BMAP_BTREE_REF))) { + INT_GET(left->bb_rightsib, ARCH_CONVERT), + 0, &rrbp, XFS_BMAP_BTREE_REF))) { XFS_BMBT_TRACE_CURSOR(cur, ERROR); goto error0; } @@ -381,10 +381,7 @@ xfs_bmbt_delrec( cur->bc_private.b.flist, mp); cur->bc_private.b.ip->i_d.di_nblocks--; xfs_trans_log_inode(cur->bc_tp, cur->bc_private.b.ip, XFS_ILOG_CORE); - if (XFS_IS_QUOTA_ON(mp) && - cur->bc_private.b.ip->i_ino != mp->m_sb.sb_uquotino && - cur->bc_private.b.ip->i_ino != mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(cur->bc_tp, cur->bc_private.b.ip, + XFS_TRANS_MOD_DQUOT_BYINO(mp, cur->bc_tp, cur->bc_private.b.ip, XFS_TRANS_DQ_BCOUNT, -1L); xfs_trans_binval(cur->bc_tp, rbp); if (bp != lbp) { @@ -680,13 +677,10 @@ xfs_bmbt_killroot( #endif memcpy(pp, cpp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, - cur->bc_private.b.flist, cur->bc_mp); + cur->bc_private.b.flist, cur->bc_mp); ip->i_d.di_nblocks--; - if (XFS_IS_QUOTA_ON(cur->bc_mp) && - ip->i_ino != cur->bc_mp->m_sb.sb_uquotino && - ip->i_ino != cur->bc_mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(cur->bc_tp, ip, XFS_TRANS_DQ_BCOUNT, - -1L); + XFS_TRANS_MOD_DQUOT_BYINO(cur->bc_mp, cur->bc_tp, ip, + XFS_TRANS_DQ_BCOUNT, -1L); xfs_trans_binval(cur->bc_tp, cbp); cur->bc_bufs[level - 1] = NULL; INT_MOD(block->bb_level, ARCH_CONVERT, -1); @@ -1283,10 +1277,7 @@ xfs_bmbt_split( cur->bc_private.b.allocated++; cur->bc_private.b.ip->i_d.di_nblocks++; xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE); - if (XFS_IS_QUOTA_ON(args.mp) && - cur->bc_private.b.ip->i_ino != args.mp->m_sb.sb_uquotino && - cur->bc_private.b.ip->i_ino != args.mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(args.tp, cur->bc_private.b.ip, + XFS_TRANS_MOD_DQUOT_BYINO(args.mp, args.tp, cur->bc_private.b.ip, XFS_TRANS_DQ_BCOUNT, 1L); rbp = xfs_btree_get_bufl(args.mp, args.tp, args.fsbno, 0); right = XFS_BUF_TO_BMBT_BLOCK(rbp); @@ -2081,11 +2072,8 @@ xfs_bmbt_newroot( cur->bc_private.b.firstblock = args.fsbno; cur->bc_private.b.allocated++; cur->bc_private.b.ip->i_d.di_nblocks++; - if (XFS_IS_QUOTA_ON(args.mp) && - cur->bc_private.b.ip->i_ino != args.mp->m_sb.sb_uquotino && - cur->bc_private.b.ip->i_ino != args.mp->m_sb.sb_gquotino) - xfs_trans_mod_dquot_byino(args.tp, cur->bc_private.b.ip, - XFS_TRANS_DQ_BCOUNT, 1L); + XFS_TRANS_MOD_DQUOT_BYINO(args.mp, args.tp, cur->bc_private.b.ip, + XFS_TRANS_DQ_BCOUNT, 1L); bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); cblock = XFS_BUF_TO_BMBT_BLOCK(bp); *cblock = *block;