1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

Merge git://oss.sgi.com:8090/oss/git/xfs-2.6

This commit is contained in:
Linus Torvalds 2005-11-03 16:25:58 -08:00
commit 0f3278d14f
178 changed files with 5784 additions and 11966 deletions

View file

@ -19,15 +19,43 @@ Mount Options
When mounting an XFS filesystem, the following options are accepted. When mounting an XFS filesystem, the following options are accepted.
biosize=size allocsize=size
Sets the preferred buffered I/O size (default size is 64K). Sets the buffered I/O end-of-file preallocation size when
"size" must be expressed as the logarithm (base2) of the doing delayed allocation writeout (default size is 64KiB).
desired I/O size. Valid values for this option are page size (typically 4KiB)
Valid values for this option are 14 through 16, inclusive through to 1GiB, inclusive, in power-of-2 increments.
(i.e. 16K, 32K, and 64K bytes). On machines with a 4K
pagesize, 13 (8K bytes) is also a valid size. attr2/noattr2
The preferred buffered I/O size can also be altered on an The options enable/disable (default is disabled for backward
individual file basis using the ioctl(2) system call. compatibility on-disk) an "opportunistic" improvement to be
made in the way inline extended attributes are stored on-disk.
When the new form is used for the first time (by setting or
removing extended attributes) the on-disk superblock feature
bit field will be updated to reflect this format being in use.
barrier
Enables the use of block layer write barriers for writes into
the journal and unwritten extent conversion. This allows for
drive level write caching to be enabled, for devices that
support write barriers.
dmapi
Enable the DMAPI (Data Management API) event callouts.
Use with the "mtpt" option.
grpid/bsdgroups and nogrpid/sysvgroups
These options define what group ID a newly created file gets.
When grpid is set, it takes the group ID of the directory in
which it is created; otherwise (the default) it takes the fsgid
of the current process, unless the directory has the setgid bit
set, in which case it takes the gid from the parent directory,
and also gets the setgid bit set if it is a directory itself.
ihashsize=value
Sets the number of hash buckets available for hashing the
in-memory inodes of the specified mount point. If a value
of zero is used, the value selected by the default algorithm
will be displayed in /proc/mounts.
ikeep/noikeep ikeep/noikeep
When inode clusters are emptied of inodes, keep them around When inode clusters are emptied of inodes, keep them around
@ -35,12 +63,31 @@ When mounting an XFS filesystem, the following options are accepted.
and is still the default for now. Using the noikeep option, and is still the default for now. Using the noikeep option,
inode clusters are returned to the free space pool. inode clusters are returned to the free space pool.
inode64
Indicates that XFS is allowed to create inodes at any location
in the filesystem, including those which will result in inode
numbers occupying more than 32 bits of significance. This is
provided for backwards compatibility, but causes problems for
backup applications that cannot handle large inode numbers.
largeio/nolargeio
If "nolargeio" is specified, the optimal I/O reported in
st_blksize by stat(2) will be as small as possible to allow user
applications to avoid inefficient read/modify/write I/O.
If "largeio" specified, a filesystem that has a "swidth" specified
will return the "swidth" value (in bytes) in st_blksize. If the
filesystem does not have a "swidth" specified but does specify
an "allocsize" then "allocsize" (in bytes) will be returned
instead.
If neither of these two options are specified, then filesystem
will behave as if "nolargeio" was specified.
logbufs=value logbufs=value
Set the number of in-memory log buffers. Valid numbers range Set the number of in-memory log buffers. Valid numbers range
from 2-8 inclusive. from 2-8 inclusive.
The default value is 8 buffers for filesystems with a The default value is 8 buffers for filesystems with a
blocksize of 64K, 4 buffers for filesystems with a blocksize blocksize of 64KiB, 4 buffers for filesystems with a blocksize
of 32K, 3 buffers for filesystems with a blocksize of 16K of 32KiB, 3 buffers for filesystems with a blocksize of 16KiB
and 2 buffers for all other configurations. Increasing the and 2 buffers for all other configurations. Increasing the
number of buffers may increase performance on some workloads number of buffers may increase performance on some workloads
at the cost of the memory used for the additional log buffers at the cost of the memory used for the additional log buffers
@ -52,7 +99,7 @@ When mounting an XFS filesystem, the following options are accepted.
Valid sizes for version 1 and version 2 logs are 16384 (16k) and Valid sizes for version 1 and version 2 logs are 16384 (16k) and
32768 (32k). Valid sizes for version 2 logs also include 32768 (32k). Valid sizes for version 2 logs also include
65536 (64k), 131072 (128k) and 262144 (256k). 65536 (64k), 131072 (128k) and 262144 (256k).
The default value for machines with more than 32MB of memory The default value for machines with more than 32MiB of memory
is 32768, machines with less memory use 16384 by default. is 32768, machines with less memory use 16384 by default.
logdev=device and rtdev=device logdev=device and rtdev=device
@ -62,6 +109,11 @@ When mounting an XFS filesystem, the following options are accepted.
optional, and the log section can be separate from the data optional, and the log section can be separate from the data
section or contained within it. section or contained within it.
mtpt=mountpoint
Use with the "dmapi" option. The value specified here will be
included in the DMAPI mount event, and should be the path of
the actual mountpoint that is used.
noalign noalign
Data allocations will not be aligned at stripe unit boundaries. Data allocations will not be aligned at stripe unit boundaries.
@ -91,13 +143,17 @@ When mounting an XFS filesystem, the following options are accepted.
O_SYNC writes can be lost if the system crashes. O_SYNC writes can be lost if the system crashes.
If timestamp updates are critical, use the osyncisosync option. If timestamp updates are critical, use the osyncisosync option.
quota/usrquota/uqnoenforce uquota/usrquota/uqnoenforce/quota
User disk quota accounting enabled, and limits (optionally) User disk quota accounting enabled, and limits (optionally)
enforced. enforced. Refer to xfs_quota(8) for further details.
grpquota/gqnoenforce gquota/grpquota/gqnoenforce
Group disk quota accounting enabled and limits (optionally) Group disk quota accounting enabled and limits (optionally)
enforced. enforced. Refer to xfs_quota(8) for further details.
pquota/prjquota/pqnoenforce
Project disk quota accounting enabled and limits (optionally)
enforced. Refer to xfs_quota(8) for further details.
sunit=value and swidth=value sunit=value and swidth=value
Used to specify the stripe unit and width for a RAID device or Used to specify the stripe unit and width for a RAID device or
@ -113,6 +169,12 @@ When mounting an XFS filesystem, the following options are accepted.
The "swidth" option is required if the "sunit" option has been The "swidth" option is required if the "sunit" option has been
specified, and must be a multiple of the "sunit" value. specified, and must be a multiple of the "sunit" value.
swalloc
Data allocations will be rounded up to stripe width boundaries
when the current end of file is being extended and the file
size is larger than the stripe width size.
sysctls sysctls
======= =======
@ -172,17 +234,29 @@ The following sysctls are available for the XFS filesystem:
Controls whether unprivileged users can use chown to "give away" Controls whether unprivileged users can use chown to "give away"
a file to another user. a file to another user.
fs.xfs.inherit_sync (Min: 0 Default: 1 Max 1) fs.xfs.inherit_sync (Min: 0 Default: 1 Max: 1)
Setting this to "1" will cause the "sync" flag set Setting this to "1" will cause the "sync" flag set
by the chattr(1) command on a directory to be by the xfs_io(8) chattr command on a directory to be
inherited by files in that directory. inherited by files in that directory.
fs.xfs.inherit_nodump (Min: 0 Default: 1 Max 1) fs.xfs.inherit_nodump (Min: 0 Default: 1 Max: 1)
Setting this to "1" will cause the "nodump" flag set Setting this to "1" will cause the "nodump" flag set
by the chattr(1) command on a directory to be by the xfs_io(8) chattr command on a directory to be
inherited by files in that directory. inherited by files in that directory.
fs.xfs.inherit_noatime (Min: 0 Default: 1 Max 1) fs.xfs.inherit_noatime (Min: 0 Default: 1 Max: 1)
Setting this to "1" will cause the "noatime" flag set Setting this to "1" will cause the "noatime" flag set
by the chattr(1) command on a directory to be by the xfs_io(8) chattr command on a directory to be
inherited by files in that directory. inherited by files in that directory.
fs.xfs.inherit_nosymlinks (Min: 0 Default: 1 Max: 1)
Setting this to "1" will cause the "nosymlinks" flag set
by the xfs_io(8) chattr command on a directory to be
inherited by files in that directory.
fs.xfs.rotorstep (Min: 1 Default: 1 Max: 256)
In "inode32" allocation mode, this option determines how many
files the allocator attempts to allocate in the same allocation
group before moving to the next allocation group. The intent
is to control the rate at which the allocator moves between
allocation groups when allocating extents for new files.

View file

@ -118,6 +118,10 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i
if (!sb->s_qcop->get_xquota) if (!sb->s_qcop->get_xquota)
return -ENOSYS; return -ENOSYS;
break; break;
case Q_XQUOTASYNC:
if (!sb->s_qcop->quota_sync)
return -ENOSYS;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
@ -128,7 +132,7 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i
(type == XQM_GRPQUOTA && !in_egroup_p(id))) && (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
!capable(CAP_SYS_ADMIN)) !capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
} else if (cmd != Q_XGETQSTAT) { } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
} }
@ -322,6 +326,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case Q_XQUOTASYNC:
return sb->s_qcop->quota_sync(sb, type);
/* We never reach here unless validity check is broken */ /* We never reach here unless validity check is broken */
default: default:
BUG(); BUG();

View file

@ -24,7 +24,7 @@ config XFS_EXPORT
default y default y
config XFS_QUOTA config XFS_QUOTA
tristate "XFS Quota support" bool "XFS Quota support"
depends on XFS_FS depends on XFS_FS
help help
If you say Y here, you will be able to set limits for disk usage on If you say Y here, you will be able to set limits for disk usage on

View file

@ -109,7 +109,6 @@ xfs-y += xfs_alloc.o \
xfs_dfrag.o \ xfs_dfrag.o \
xfs_log.o \ xfs_log.o \
xfs_log_recover.o \ xfs_log_recover.o \
xfs_macros.o \
xfs_mount.o \ xfs_mount.o \
xfs_rename.o \ xfs_rename.o \
xfs_trans.o \ xfs_trans.o \

View file

@ -1,49 +1,32 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include "time.h" #include "time.h"
#include "kmem.h" #include "kmem.h"
#define MAX_VMALLOCS 6 #define MAX_VMALLOCS 6
#define MAX_SLAB_SIZE 0x20000 #define MAX_SLAB_SIZE 0x20000
void * void *
kmem_alloc(size_t size, unsigned int __nocast flags) kmem_alloc(size_t size, unsigned int __nocast flags)
{ {

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_KMEM_H__ #ifndef __XFS_SUPPORT_KMEM_H__
#define __XFS_SUPPORT_KMEM_H__ #define __XFS_SUPPORT_KMEM_H__
@ -83,7 +69,7 @@ typedef unsigned long xfs_pflags_t;
static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
{ {
gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */
#ifdef DEBUG #ifdef DEBUG
if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
@ -125,13 +111,13 @@ kmem_zone_destroy(kmem_zone_t *zone)
BUG(); BUG();
} }
extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
extern void *kmem_alloc(size_t, unsigned int __nocast); extern void *kmem_alloc(size_t, unsigned int __nocast);
extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
extern void *kmem_zalloc(size_t, unsigned int __nocast); extern void *kmem_zalloc(size_t, unsigned int __nocast);
extern void kmem_free(void *, size_t); extern void kmem_free(void *, size_t);
typedef struct shrinker *kmem_shaker_t; typedef struct shrinker *kmem_shaker_t;
typedef int (*kmem_shake_func_t)(int, gfp_t); typedef int (*kmem_shake_func_t)(int, gfp_t);

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_MRLOCK_H__ #ifndef __XFS_SUPPORT_MRLOCK_H__
#define __XFS_SUPPORT_MRLOCK_H__ #define __XFS_SUPPORT_MRLOCK_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_MUTEX_H__ #ifndef __XFS_SUPPORT_MUTEX_H__
#define __XFS_SUPPORT_MUTEX_H__ #define __XFS_SUPPORT_MUTEX_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_SEMA_H__ #ifndef __XFS_SUPPORT_SEMA_H__
#define __XFS_SUPPORT_SEMA_H__ #define __XFS_SUPPORT_SEMA_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_SPIN_H__ #ifndef __XFS_SUPPORT_SPIN_H__
#define __XFS_SUPPORT_SPIN_H__ #define __XFS_SUPPORT_SPIN_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_SV_H__ #ifndef __XFS_SUPPORT_SV_H__
#define __XFS_SUPPORT_SV_H__ #define __XFS_SUPPORT_SV_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_TIME_H__ #ifndef __XFS_SUPPORT_TIME_H__
#define __XFS_SUPPORT_TIME_H__ #define __XFS_SUPPORT_TIME_H__

View file

@ -1,39 +1,26 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_trans.h" #include "xfs_trans.h"
@ -42,13 +29,13 @@
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h" #include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_iomap.h" #include "xfs_iomap.h"
@ -761,8 +748,9 @@ xfs_page_state_convert(
if (page->index >= end_index) { if (page->index >= end_index) {
if ((page->index >= end_index + 1) || if ((page->index >= end_index + 1) ||
!(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
err = -EIO; if (startio)
goto error; unlock_page(page);
return 0;
} }
} }
@ -948,15 +936,18 @@ __linvfs_get_block(
{ {
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
xfs_iomap_t iomap; xfs_iomap_t iomap;
xfs_off_t offset;
ssize_t size;
int retpbbm = 1; int retpbbm = 1;
int error; int error;
ssize_t size;
loff_t offset = (loff_t)iblock << inode->i_blkbits;
if (blocks) if (blocks) {
size = blocks << inode->i_blkbits; offset = blocks << inode->i_blkbits; /* 64 bit goodness */
else size = (ssize_t) min_t(xfs_off_t, offset, LONG_MAX);
} else {
size = 1 << inode->i_blkbits; size = 1 << inode->i_blkbits;
}
offset = (xfs_off_t)iblock << inode->i_blkbits;
VOP_BMAP(vp, offset, size, VOP_BMAP(vp, offset, size,
create ? flags : BMAPI_READ, &iomap, &retpbbm, error); create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
@ -967,8 +958,8 @@ __linvfs_get_block(
return 0; return 0;
if (iomap.iomap_bn != IOMAP_DADDR_NULL) { if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
xfs_daddr_t bn; xfs_daddr_t bn;
loff_t delta; xfs_off_t delta;
/* For unwritten extents do not report a disk address on /* For unwritten extents do not report a disk address on
* the read case (treat as if we're reading into a hole). * the read case (treat as if we're reading into a hole).
@ -1000,9 +991,8 @@ __linvfs_get_block(
*/ */
if (create && if (create &&
((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
(offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) { (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW)))
set_buffer_new(bh_result); set_buffer_new(bh_result);
}
if (iomap.iomap_flags & IOMAP_DELAY) { if (iomap.iomap_flags & IOMAP_DELAY) {
BUG_ON(direct); BUG_ON(direct);
@ -1014,9 +1004,11 @@ __linvfs_get_block(
} }
if (blocks) { if (blocks) {
bh_result->b_size = (ssize_t)min( ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0);
(loff_t)(iomap.iomap_bsize - iomap.iomap_delta), offset = min_t(xfs_off_t,
(loff_t)(blocks << inode->i_blkbits)); iomap.iomap_bsize - iomap.iomap_delta,
blocks << inode->i_blkbits);
bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset);
} }
return 0; return 0;

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_AOPS_H__ #ifndef __XFS_AOPS_H__
#define __XFS_AOPS_H__ #define __XFS_AOPS_H__

View file

@ -1,46 +1,20 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* The xfs_buf.c code provides an abstract buffer cache model on top
* of the Linux page cache. Cached metadata blocks for a file system
* are hashed to the inode for the block device. xfs_buf.c assembles
* buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O.
*
* Written by Steve Lord, Jim Mostek, Russell Cattelan
* and Rajagopal Ananthanarayanan ("ananth") at SGI.
*
*/
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -55,13 +29,8 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/hash.h> #include <linux/hash.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include "xfs_linux.h" #include "xfs_linux.h"
/*
* File wide globals
*/
STATIC kmem_cache_t *pagebuf_zone; STATIC kmem_cache_t *pagebuf_zone;
STATIC kmem_shaker_t pagebuf_shake; STATIC kmem_shaker_t pagebuf_shake;
STATIC int xfsbufd_wakeup(int, gfp_t); STATIC int xfsbufd_wakeup(int, gfp_t);
@ -70,10 +39,6 @@ STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
STATIC struct workqueue_struct *xfslogd_workqueue; STATIC struct workqueue_struct *xfslogd_workqueue;
struct workqueue_struct *xfsdatad_workqueue; struct workqueue_struct *xfsdatad_workqueue;
/*
* Pagebuf debugging
*/
#ifdef PAGEBUF_TRACE #ifdef PAGEBUF_TRACE
void void
pagebuf_trace( pagebuf_trace(
@ -112,10 +77,6 @@ ktrace_t *pagebuf_trace_buf;
# define PB_GET_OWNER(pb) do { } while (0) # define PB_GET_OWNER(pb) do { } while (0)
#endif #endif
/*
* Pagebuf allocation / freeing.
*/
#define pb_to_gfp(flags) \ #define pb_to_gfp(flags) \
((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \ ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \
((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
@ -123,7 +84,6 @@ ktrace_t *pagebuf_trace_buf;
#define pb_to_km(flags) \ #define pb_to_km(flags) \
(((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
#define pagebuf_allocate(flags) \ #define pagebuf_allocate(flags) \
kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) kmem_zone_alloc(pagebuf_zone, pb_to_km(flags))
#define pagebuf_deallocate(pb) \ #define pagebuf_deallocate(pb) \
@ -286,7 +246,7 @@ _pagebuf_initialize(
* most cases but may be reset (e.g. XFS recovery). * most cases but may be reset (e.g. XFS recovery).
*/ */
pb->pb_buffer_length = pb->pb_count_desired = range_length; pb->pb_buffer_length = pb->pb_count_desired = range_length;
pb->pb_flags = flags | PBF_NONE; pb->pb_flags = flags;
pb->pb_bn = XFS_BUF_DADDR_NULL; pb->pb_bn = XFS_BUF_DADDR_NULL;
atomic_set(&pb->pb_pin_count, 0); atomic_set(&pb->pb_pin_count, 0);
init_waitqueue_head(&pb->pb_waiters); init_waitqueue_head(&pb->pb_waiters);
@ -458,14 +418,8 @@ _pagebuf_lookup_pages(
unlock_page(bp->pb_pages[i]); unlock_page(bp->pb_pages[i]);
} }
if (page_count) { if (page_count == bp->pb_page_count)
/* if we have any uptodate pages, mark that in the buffer */ bp->pb_flags |= PBF_DONE;
bp->pb_flags &= ~PBF_NONE;
/* if some pages aren't uptodate, mark that in the buffer */
if (page_count != bp->pb_page_count)
bp->pb_flags |= PBF_PARTIAL;
}
PB_TRACE(bp, "lookup_pages", (long)page_count); PB_TRACE(bp, "lookup_pages", (long)page_count);
return error; return error;
@ -676,7 +630,7 @@ xfs_buf_read_flags(
pb = xfs_buf_get_flags(target, ioff, isize, flags); pb = xfs_buf_get_flags(target, ioff, isize, flags);
if (pb) { if (pb) {
if (PBF_NOT_DONE(pb)) { if (!XFS_BUF_ISDONE(pb)) {
PB_TRACE(pb, "read", (unsigned long)flags); PB_TRACE(pb, "read", (unsigned long)flags);
XFS_STATS_INC(pb_get_read); XFS_STATS_INC(pb_get_read);
pagebuf_iostart(pb, flags); pagebuf_iostart(pb, flags);
@ -813,7 +767,7 @@ pagebuf_get_no_daddr(
bp = pagebuf_allocate(0); bp = pagebuf_allocate(0);
if (unlikely(bp == NULL)) if (unlikely(bp == NULL))
goto fail; goto fail;
_pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO); _pagebuf_initialize(bp, target, 0, len, 0);
try_again: try_again:
data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL);
@ -876,39 +830,18 @@ pagebuf_rele(
PB_TRACE(pb, "rele", pb->pb_relse); PB_TRACE(pb, "rele", pb->pb_relse);
/*
* pagebuf_lookup buffers are not hashed, not delayed write,
* and don't have their own release routines. Special case.
*/
if (unlikely(!hash)) {
ASSERT(!pb->pb_relse);
if (atomic_dec_and_test(&pb->pb_hold))
xfs_buf_free(pb);
return;
}
if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) { if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) {
int do_free = 1;
if (pb->pb_relse) { if (pb->pb_relse) {
atomic_inc(&pb->pb_hold); atomic_inc(&pb->pb_hold);
spin_unlock(&hash->bh_lock); spin_unlock(&hash->bh_lock);
(*(pb->pb_relse)) (pb); (*(pb->pb_relse)) (pb);
spin_lock(&hash->bh_lock); } else if (pb->pb_flags & PBF_FS_MANAGED) {
do_free = 0; spin_unlock(&hash->bh_lock);
} } else {
ASSERT(!(pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)));
if (pb->pb_flags & PBF_FS_MANAGED) {
do_free = 0;
}
if (do_free) {
ASSERT((pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)) == 0);
list_del_init(&pb->pb_hash_list); list_del_init(&pb->pb_hash_list);
spin_unlock(&hash->bh_lock); spin_unlock(&hash->bh_lock);
pagebuf_free(pb); pagebuf_free(pb);
} else {
spin_unlock(&hash->bh_lock);
} }
} else { } else {
/* /*
@ -1121,21 +1054,18 @@ pagebuf_iodone_work(
void void
pagebuf_iodone( pagebuf_iodone(
xfs_buf_t *pb, xfs_buf_t *pb,
int dataio,
int schedule) int schedule)
{ {
pb->pb_flags &= ~(PBF_READ | PBF_WRITE); pb->pb_flags &= ~(PBF_READ | PBF_WRITE);
if (pb->pb_error == 0) { if (pb->pb_error == 0)
pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE); pb->pb_flags |= PBF_DONE;
}
PB_TRACE(pb, "iodone", pb->pb_iodone); PB_TRACE(pb, "iodone", pb->pb_iodone);
if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
if (schedule) { if (schedule) {
INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
queue_work(dataio ? xfsdatad_workqueue : queue_work(xfslogd_workqueue, &pb->pb_iodone_work);
xfslogd_workqueue, &pb->pb_iodone_work);
} else { } else {
pagebuf_iodone_work(pb); pagebuf_iodone_work(pb);
} }
@ -1235,7 +1165,7 @@ _pagebuf_iodone(
{ {
if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
pb->pb_locked = 0; pb->pb_locked = 0;
pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule); pagebuf_iodone(pb, schedule);
} }
} }
@ -1304,6 +1234,11 @@ _pagebuf_ioapply(
rw = (pb->pb_flags & PBF_READ) ? READ : WRITE; rw = (pb->pb_flags & PBF_READ) ? READ : WRITE;
} }
if (pb->pb_flags & PBF_ORDERED) {
ASSERT(!(pb->pb_flags & PBF_READ));
rw = WRITE_BARRIER;
}
/* Special code path for reading a sub page size pagebuf in -- /* Special code path for reading a sub page size pagebuf in --
* we populate up the whole page, and hence the other metadata * we populate up the whole page, and hence the other metadata
* in the same page. This optimization is only valid when the * in the same page. This optimization is only valid when the
@ -1750,8 +1685,8 @@ STATIC int xfsbufd_force_sleep;
STATIC int STATIC int
xfsbufd_wakeup( xfsbufd_wakeup(
int priority, int priority,
gfp_t mask) gfp_t mask)
{ {
if (xfsbufd_force_sleep) if (xfsbufd_force_sleep)
return 0; return 0;
@ -1781,8 +1716,8 @@ xfsbufd(
xfsbufd_force_sleep = 0; xfsbufd_force_sleep = 0;
} }
schedule_timeout_interruptible schedule_timeout_interruptible(
(xfs_buf_timer_centisecs * msecs_to_jiffies(10)); xfs_buf_timer_centisecs * msecs_to_jiffies(10));
age = xfs_buf_age_centisecs * msecs_to_jiffies(10); age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
spin_lock(&pbd_delwrite_lock); spin_lock(&pbd_delwrite_lock);
@ -1891,14 +1826,22 @@ xfs_flush_buftarg(
return pincount; return pincount;
} }
STATIC int int __init
xfs_buf_daemons_start(void) pagebuf_init(void)
{ {
int error = -ENOMEM; int error = -ENOMEM;
#ifdef PAGEBUF_TRACE
pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
#endif
pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
if (!pagebuf_zone)
goto out_free_trace_buf;
xfslogd_workqueue = create_workqueue("xfslogd"); xfslogd_workqueue = create_workqueue("xfslogd");
if (!xfslogd_workqueue) if (!xfslogd_workqueue)
goto out; goto out_free_buf_zone;
xfsdatad_workqueue = create_workqueue("xfsdatad"); xfsdatad_workqueue = create_workqueue("xfsdatad");
if (!xfsdatad_workqueue) if (!xfsdatad_workqueue)
@ -1909,82 +1852,37 @@ xfs_buf_daemons_start(void)
error = PTR_ERR(xfsbufd_task); error = PTR_ERR(xfsbufd_task);
goto out_destroy_xfsdatad_workqueue; goto out_destroy_xfsdatad_workqueue;
} }
pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
if (!pagebuf_shake)
goto out_stop_xfsbufd;
return 0; return 0;
out_stop_xfsbufd:
kthread_stop(xfsbufd_task);
out_destroy_xfsdatad_workqueue: out_destroy_xfsdatad_workqueue:
destroy_workqueue(xfsdatad_workqueue); destroy_workqueue(xfsdatad_workqueue);
out_destroy_xfslogd_workqueue: out_destroy_xfslogd_workqueue:
destroy_workqueue(xfslogd_workqueue); destroy_workqueue(xfslogd_workqueue);
out:
return error;
}
/*
* Note: do not mark as __exit, it is called from pagebuf_terminate.
*/
STATIC void
xfs_buf_daemons_stop(void)
{
kthread_stop(xfsbufd_task);
destroy_workqueue(xfslogd_workqueue);
destroy_workqueue(xfsdatad_workqueue);
}
/*
* Initialization and Termination
*/
int __init
pagebuf_init(void)
{
int error = -ENOMEM;
pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
if (!pagebuf_zone)
goto out;
#ifdef PAGEBUF_TRACE
pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
#endif
error = xfs_buf_daemons_start();
if (error)
goto out_free_buf_zone;
pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
if (!pagebuf_shake) {
error = -ENOMEM;
goto out_stop_daemons;
}
return 0;
out_stop_daemons:
xfs_buf_daemons_stop();
out_free_buf_zone: out_free_buf_zone:
kmem_zone_destroy(pagebuf_zone);
out_free_trace_buf:
#ifdef PAGEBUF_TRACE #ifdef PAGEBUF_TRACE
ktrace_free(pagebuf_trace_buf); ktrace_free(pagebuf_trace_buf);
#endif #endif
kmem_zone_destroy(pagebuf_zone);
out:
return error; return error;
} }
/*
* pagebuf_terminate.
*
* Note: do not mark as __exit, this is also called from the __init code.
*/
void void
pagebuf_terminate(void) pagebuf_terminate(void)
{ {
xfs_buf_daemons_stop(); kmem_shake_deregister(pagebuf_shake);
kthread_stop(xfsbufd_task);
destroy_workqueue(xfsdatad_workqueue);
destroy_workqueue(xfslogd_workqueue);
kmem_zone_destroy(pagebuf_zone);
#ifdef PAGEBUF_TRACE #ifdef PAGEBUF_TRACE
ktrace_free(pagebuf_trace_buf); ktrace_free(pagebuf_trace_buf);
#endif #endif
kmem_zone_destroy(pagebuf_zone);
kmem_shake_deregister(pagebuf_shake);
} }

View file

@ -1,39 +1,20 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI
*/
#ifndef __XFS_BUF_H__ #ifndef __XFS_BUF_H__
#define __XFS_BUF_H__ #define __XFS_BUF_H__
@ -69,15 +50,12 @@ typedef enum page_buf_flags_e { /* pb_flags values */
PBF_READ = (1 << 0), /* buffer intended for reading from device */ PBF_READ = (1 << 0), /* buffer intended for reading from device */
PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ PBF_WRITE = (1 << 1), /* buffer intended for writing to device */
PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */
PBF_PARTIAL = (1 << 3), /* buffer partially read */
PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */
PBF_NONE = (1 << 5), /* buffer not read at all */ PBF_DONE = (1 << 5), /* all pages in the buffer uptodate */
PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ PBF_DELWRI = (1 << 6), /* buffer has dirty pages */
PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */
PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */
PBF_FS_DATAIOD = (1 << 9), /* schedule IO completion on fs datad */ PBF_ORDERED = (1 << 11), /* use ordered writes */
PBF_FORCEIO = (1 << 10), /* ignore any cache state */
PBF_FLUSH = (1 << 11), /* flush disk write cache */
PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
/* flags used only as arguments to access routines */ /* flags used only as arguments to access routines */
@ -92,9 +70,6 @@ typedef enum page_buf_flags_e { /* pb_flags values */
_PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
} page_buf_flags_t; } page_buf_flags_t;
#define PBF_UPDATE (PBF_READ | PBF_WRITE)
#define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
#define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
typedef struct xfs_bufhash { typedef struct xfs_bufhash {
struct list_head bh_list; struct list_head bh_list;
@ -258,7 +233,6 @@ extern void pagebuf_unlock( /* unlock buffer */
extern void pagebuf_iodone( /* mark buffer I/O complete */ extern void pagebuf_iodone( /* mark buffer I/O complete */
xfs_buf_t *, /* buffer to mark */ xfs_buf_t *, /* buffer to mark */
int, /* use data/log helper thread. */
int); /* run completion locally, or in int); /* run completion locally, or in
* a helper thread. */ * a helper thread. */
@ -378,21 +352,21 @@ extern void pagebuf_trace(
#define XFS_BUF_GETERROR(x) pagebuf_geterror(x) #define XFS_BUF_GETERROR(x) pagebuf_geterror(x)
#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) #define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0)
#define XFS_BUF_DONE(x) ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE)) #define XFS_BUF_DONE(x) ((x)->pb_flags |= PBF_DONE)
#define XFS_BUF_UNDONE(x) ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE) #define XFS_BUF_UNDONE(x) ((x)->pb_flags &= ~PBF_DONE)
#define XFS_BUF_ISDONE(x) (!(PBF_NOT_DONE(x))) #define XFS_BUF_ISDONE(x) ((x)->pb_flags & PBF_DONE)
#define XFS_BUF_BUSY(x) ((x)->pb_flags |= PBF_FORCEIO) #define XFS_BUF_BUSY(x) do { } while (0)
#define XFS_BUF_UNBUSY(x) ((x)->pb_flags &= ~PBF_FORCEIO) #define XFS_BUF_UNBUSY(x) do { } while (0)
#define XFS_BUF_ISBUSY(x) (1) #define XFS_BUF_ISBUSY(x) (1)
#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC) #define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC)
#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC) #define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC)
#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC) #define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC)
#define XFS_BUF_FLUSH(x) ((x)->pb_flags |= PBF_FLUSH) #define XFS_BUF_ORDERED(x) ((x)->pb_flags |= PBF_ORDERED)
#define XFS_BUF_UNFLUSH(x) ((x)->pb_flags &= ~PBF_FLUSH) #define XFS_BUF_UNORDERED(x) ((x)->pb_flags &= ~PBF_ORDERED)
#define XFS_BUF_ISFLUSH(x) ((x)->pb_flags & PBF_FLUSH) #define XFS_BUF_ISORDERED(x) ((x)->pb_flags & PBF_ORDERED)
#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n") #define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n")
#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n") #define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n")
@ -412,9 +386,6 @@ extern void pagebuf_trace(
#define XFS_BUF_BP_ISMAPPED(bp) 1 #define XFS_BUF_BP_ISMAPPED(bp) 1
#define XFS_BUF_DATAIO(x) ((x)->pb_flags |= PBF_FS_DATAIOD)
#define XFS_BUF_UNDATAIO(x) ((x)->pb_flags &= ~PBF_FS_DATAIOD)
#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone #define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone
#define XFS_BUF_SET_IODONE_FUNC(buf, func) \ #define XFS_BUF_SET_IODONE_FUNC(buf, func) \
(buf)->pb_iodone = (func) (buf)->pb_iodone = (func)
@ -510,7 +481,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
#define xfs_biodone(pb) \ #define xfs_biodone(pb) \
pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0) pagebuf_iodone(pb, 0)
#define xfs_biomove(pb, off, len, data, rw) \ #define xfs_biomove(pb, off, len, data, rw) \
pagebuf_iomove((pb), (off), (len), (data), \ pagebuf_iomove((pb), (off), (len), (data), \

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_CRED_H__ #ifndef __XFS_CRED_H__
#define __XFS_CRED_H__ #define __XFS_CRED_H__

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2004-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
@ -41,7 +26,7 @@
#include "xfs_export.h" #include "xfs_export.h"
/* /*
* XFS encode and decodes the fileid portion of NFS filehandles * XFS encodes and decodes the fileid portion of NFS filehandles
* itself instead of letting the generic NFS code do it. This * itself instead of letting the generic NFS code do it. This
* allows filesystems with 64 bit inode numbers to be exported. * allows filesystems with 64 bit inode numbers to be exported.
* *
@ -51,7 +36,6 @@
* remains in that code. * remains in that code.
*/ */
STATIC struct dentry * STATIC struct dentry *
linvfs_decode_fh( linvfs_decode_fh(
struct super_block *sb, struct super_block *sb,
@ -112,9 +96,8 @@ linvfs_encode_fh(
int is64 = 0; int is64 = 0;
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb);
xfs_mount_t *mp = XFS_VFSTOM(vfs);
if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) { if (!(vfs->vfs_flag & VFS_32BITINODES)) {
/* filesystem may contain 64bit inode numbers */ /* filesystem may contain 64bit inode numbers */
is64 = XFS_FILEID_TYPE_64FLAG; is64 = XFS_FILEID_TYPE_64FLAG;
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_EXPORT_H__ #ifndef __XFS_EXPORT_H__
#define __XFS_EXPORT_H__ #define __XFS_EXPORT_H__

View file

@ -1,39 +1,26 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_trans.h" #include "xfs_trans.h"

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
@ -117,6 +103,8 @@ fs_flush_pages(
if (VN_CACHED(vp)) { if (VN_CACHED(vp)) {
filemap_fdatawrite(ip->i_mapping); filemap_fdatawrite(ip->i_mapping);
if (flags & XFS_B_ASYNC)
return 0;
filemap_fdatawait(ip->i_mapping); filemap_fdatawait(ip->i_mapping);
} }

View file

@ -1,48 +1,29 @@
/* /*
* Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUBR_H__
#define __XFS_SUBR_H__
/*
* Utilities shared among file system implementations.
*/ */
#ifndef __XFS_FS_SUBR_H__
#define __XFS_FS_SUBR_H__
struct cred; struct cred;
extern int fs_noerr(void);
extern int fs_noerr(void); extern int fs_nosys(void);
extern int fs_nosys(void); extern void fs_noval(void);
extern void fs_noval(void); extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
#endif /* __XFS_FS_SUBR_H__ */ #endif /* __XFS_FS_SUBR_H__ */

View file

@ -1,40 +1,20 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* This file contains globals needed by XFS that were normally defined
* somewhere else in IRIX.
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_cred.h" #include "xfs_cred.h"
#include "xfs_sysctl.h" #include "xfs_sysctl.h"

View file

@ -1,42 +1,23 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_GLOBALS_H__ #ifndef __XFS_GLOBALS_H__
#define __XFS_GLOBALS_H__ #define __XFS_GLOBALS_H__
/*
* This file declares globals needed by XFS that were normally defined
* somewhere else in IRIX.
*/
extern uint64_t xfs_panic_mask; /* set to cause more panics */ extern uint64_t xfs_panic_mask; /* set to cause more panics */
extern unsigned long xfs_physmem; extern unsigned long xfs_physmem;
extern struct cred *sys_cred; extern struct cred *sys_cred;

View file

@ -1,67 +1,52 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_btree.h"
#include "xfs_bit.h" #include "xfs_ialloc.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
#include "xfs_error.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
#include "xfs_mac.h" #include "xfs_mac.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_bmap.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_utils.h" #include "xfs_utils.h"
#include "xfs_dfrag.h" #include "xfs_dfrag.h"

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2004-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/init.h> #include <linux/init.h>
@ -39,7 +24,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "xfs.h" #include "xfs.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_fs.h" #include "xfs_fs.h"

View file

@ -1,34 +1,24 @@
/* /*
* Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2004-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_IOCTL32_H__
#define __XFS_IOCTL32_H__
long linvfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long);
long linvfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg); extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long);
#endif /* __XFS_IOCTL32_H__ */

View file

@ -1,39 +1,25 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,18 +29,17 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
@ -69,6 +54,137 @@
#include <linux/xattr.h> #include <linux/xattr.h>
#include <linux/namei.h> #include <linux/namei.h>
/*
* Change the requested timestamp in the given inode.
* We don't lock across timestamp updates, and we don't log them but
* we do record the fact that there is dirty information in core.
*
* NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
* with XFS_ICHGTIME_ACC to be sure that access time
* update will take. Calling first with XFS_ICHGTIME_ACC
* and then XFS_ICHGTIME_MOD may fail to modify the access
* timestamp if the filesystem is mounted noacctm.
*/
void
xfs_ichgtime(
xfs_inode_t *ip,
int flags)
{
struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
timespec_t tv;
/*
* We're not supposed to change timestamps in readonly-mounted
* filesystems. Throw it away if anyone asks us.
*/
if (unlikely(IS_RDONLY(inode)))
return;
/*
* Don't update access timestamps on reads if mounted "noatime".
* Throw it away if anyone asks us.
*/
if (unlikely(
(ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
(flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
XFS_ICHGTIME_ACC))
return;
nanotime(&tv);
if (flags & XFS_ICHGTIME_MOD) {
inode->i_mtime = tv;
ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
}
if (flags & XFS_ICHGTIME_ACC) {
inode->i_atime = tv;
ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
}
if (flags & XFS_ICHGTIME_CHG) {
inode->i_ctime = tv;
ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
}
/*
* We update the i_update_core field _after_ changing
* the timestamps in order to coordinate properly with
* xfs_iflush() so that we don't lose timestamp updates.
* This keeps us from having to hold the inode lock
* while doing this. We use the SYNCHRONIZE macro to
* ensure that the compiler does not reorder the update
* of i_update_core above the timestamp updates above.
*/
SYNCHRONIZE();
ip->i_update_core = 1;
if (!(inode->i_state & I_LOCK))
mark_inode_dirty_sync(inode);
}
/*
* Variant on the above which avoids querying the system clock
* in situations where we know the Linux inode timestamps have
* just been updated (and so we can update our inode cheaply).
* We also skip the readonly and noatime checks here, they are
* also catered for already.
*/
void
xfs_ichgtime_fast(
xfs_inode_t *ip,
struct inode *inode,
int flags)
{
timespec_t *tvp;
/*
* We're not supposed to change timestamps in readonly-mounted
* filesystems. Throw it away if anyone asks us.
*/
if (unlikely(IS_RDONLY(inode)))
return;
/*
* Don't update access timestamps on reads if mounted "noatime".
* Throw it away if anyone asks us.
*/
if (unlikely(
(ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
XFS_ICHGTIME_ACC)))
return;
if (flags & XFS_ICHGTIME_MOD) {
tvp = &inode->i_mtime;
ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
}
if (flags & XFS_ICHGTIME_ACC) {
tvp = &inode->i_atime;
ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec;
ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec;
}
if (flags & XFS_ICHGTIME_CHG) {
tvp = &inode->i_ctime;
ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec;
}
/*
* We update the i_update_core field _after_ changing
* the timestamps in order to coordinate properly with
* xfs_iflush() so that we don't lose timestamp updates.
* This keeps us from having to hold the inode lock
* while doing this. We use the SYNCHRONIZE macro to
* ensure that the compiler does not reorder the update
* of i_update_core above the timestamp updates above.
*/
SYNCHRONIZE();
ip->i_update_core = 1;
if (!(inode->i_state & I_LOCK))
mark_inode_dirty_sync(inode);
}
/* /*
* Pull the link count and size up from the xfs inode to the linux inode * Pull the link count and size up from the xfs inode to the linux inode

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_IOPS_H__ #ifndef __XFS_IOPS_H__
#define __XFS_IOPS_H__ #define __XFS_IOPS_H__
@ -48,4 +34,8 @@ extern void linvfs_unwritten_done(struct buffer_head *, int);
extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
int, unsigned int, void __user *); int, unsigned int, void __user *);
struct xfs_inode;
extern void xfs_ichgtime(struct xfs_inode *, int);
extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
#endif /* __XFS_IOPS_H__ */ #endif /* __XFS_IOPS_H__ */

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_LINUX__ #ifndef __XFS_LINUX__
#define __XFS_LINUX__ #define __XFS_LINUX__
@ -197,10 +183,6 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
/* bytes to clicks */ /* bytes to clicks */
#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) #define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
#ifndef CELL_CAPABLE
#define FSC_NOTIFY_NAME_CHANGED(vp)
#endif
#ifndef ENOATTR #ifndef ENOATTR
#define ENOATTR ENODATA /* Attribute not found */ #define ENOATTR ENODATA /* Attribute not found */
#endif #endif
@ -235,30 +217,18 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ #define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ #define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ #define dfltprid 0
/* we may well need to fine-tune this if it ever becomes an issue. */
#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */
#define ndquot DQUOT_MAX_HEURISTIC
/* IRIX uses the current size of the name cache to guess a good value */
/* - this isn't the same but is a good enough starting point for now. */
#define DQUOT_HASH_HEURISTIC files_stat.nr_files
/* IRIX inodes maintain the project ID also, zero this field on Linux */
#define DEFAULT_PROJID 0
#define dfltprid DEFAULT_PROJID
#define MAXPATHLEN 1024 #define MAXPATHLEN 1024
#define MIN(a,b) (min(a,b)) #define MIN(a,b) (min(a,b))
#define MAX(a,b) (max(a,b)) #define MAX(a,b) (max(a,b))
#define howmany(x, y) (((x)+((y)-1))/(y)) #define howmany(x, y) (((x)+((y)-1))/(y))
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
#define qsort(a,n,s,fn) sort(a,n,s,fn,NULL)
/* /*
* Various platform dependent calls that don't fit anywhere else * Various platform dependent calls that don't fit anywhere else
*/ */
#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
#define xfs_stack_trace() dump_stack() #define xfs_stack_trace() dump_stack()
#define xfs_itruncate_data(ip, off) \ #define xfs_itruncate_data(ip, off) \
(-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))

View file

@ -1,44 +1,25 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
*
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -48,18 +29,17 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
@ -302,7 +282,7 @@ xfs_read(
xfs_iunlock(ip, XFS_IOLOCK_SHARED); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
if (likely(!(ioflags & IO_INVIS))) if (likely(!(ioflags & IO_INVIS)))
xfs_ichgtime(ip, XFS_ICHGTIME_ACC); xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC);
unlock_isem: unlock_isem:
if (unlikely(ioflags & IO_ISDIRECT)) if (unlikely(ioflags & IO_ISDIRECT))
@ -367,7 +347,7 @@ xfs_sendfile(
XFS_STATS_ADD(xs_read_bytes, ret); XFS_STATS_ADD(xs_read_bytes, ret);
if (likely(!(ioflags & IO_INVIS))) if (likely(!(ioflags & IO_INVIS)))
xfs_ichgtime(ip, XFS_ICHGTIME_ACC); xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC);
return ret; return ret;
} }
@ -732,15 +712,10 @@ start:
} }
} }
/* if (likely(!(ioflags & IO_INVIS))) {
* On Linux, generic_file_write updates the times even if
* no data is copied in so long as the write had a size.
*
* We must update xfs' times since revalidate will overcopy xfs.
*/
if (!(ioflags & IO_INVIS)) {
xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
inode_update_time(inode, 1); inode_update_time(inode, 1);
xfs_ichgtime_fast(xip, inode,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
} }
/* /*

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_LRW_H__ #ifndef __XFS_LRW_H__
#define __XFS_LRW_H__ #define __XFS_LRW_H__
@ -107,9 +93,4 @@ extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
extern int xfs_dev_is_read_only(struct xfs_mount *, char *); extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
#define XFS_FSB_TO_DB_IO(io,fsb) \
(((io)->io_flags & XFS_IOCORE_RT) ? \
XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
#endif /* __XFS_LRW_H__ */ #endif /* __XFS_LRW_H__ */

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include <linux/proc_fs.h> #include <linux/proc_fs.h>

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_STATS_H__ #ifndef __XFS_STATS_H__
#define __XFS_STATS_H__ #define __XFS_STATS_H__

View file

@ -1,60 +1,45 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_bit.h"
#include "xfs_inum.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_clnt.h" #include "xfs_clnt.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
@ -189,7 +174,7 @@ xfs_revalidate_inode(
break; break;
} }
inode->i_blksize = PAGE_CACHE_SIZE; inode->i_blksize = xfs_preferred_iosize(mp);
inode->i_generation = ip->i_d.di_gen; inode->i_generation = ip->i_d.di_gen;
i_size_write(inode, ip->i_d.di_size); i_size_write(inode, ip->i_d.di_size);
inode->i_blocks = inode->i_blocks =
@ -278,6 +263,72 @@ xfs_blkdev_put(
close_bdev_excl(bdev); close_bdev_excl(bdev);
} }
/*
* Try to write out the superblock using barriers.
*/
STATIC int
xfs_barrier_test(
xfs_mount_t *mp)
{
xfs_buf_t *sbp = xfs_getsb(mp, 0);
int error;
XFS_BUF_UNDONE(sbp);
XFS_BUF_UNREAD(sbp);
XFS_BUF_UNDELAYWRITE(sbp);
XFS_BUF_WRITE(sbp);
XFS_BUF_UNASYNC(sbp);
XFS_BUF_ORDERED(sbp);
xfsbdstrat(mp, sbp);
error = xfs_iowait(sbp);
/*
* Clear all the flags we set and possible error state in the
* buffer. We only did the write to try out whether barriers
* worked and shouldn't leave any traces in the superblock
* buffer.
*/
XFS_BUF_DONE(sbp);
XFS_BUF_ERROR(sbp, 0);
XFS_BUF_UNORDERED(sbp);
xfs_buf_relse(sbp);
return error;
}
void
xfs_mountfs_check_barriers(xfs_mount_t *mp)
{
int error;
if (mp->m_logdev_targp != mp->m_ddev_targp) {
xfs_fs_cmn_err(CE_NOTE, mp,
"Disabling barriers, not supported with external log device");
mp->m_flags &= ~XFS_MOUNT_BARRIER;
}
if (mp->m_ddev_targp->pbr_bdev->bd_disk->queue->ordered ==
QUEUE_ORDERED_NONE) {
xfs_fs_cmn_err(CE_NOTE, mp,
"Disabling barriers, not supported by the underlying device");
mp->m_flags &= ~XFS_MOUNT_BARRIER;
}
error = xfs_barrier_test(mp);
if (error) {
xfs_fs_cmn_err(CE_NOTE, mp,
"Disabling barriers, trial barrier write failed");
mp->m_flags &= ~XFS_MOUNT_BARRIER;
}
}
void
xfs_blkdev_issue_flush(
xfs_buftarg_t *buftarg)
{
blkdev_issue_flush(buftarg->pbr_bdev, NULL);
}
STATIC struct inode * STATIC struct inode *
linvfs_alloc_inode( linvfs_alloc_inode(
@ -700,6 +751,18 @@ linvfs_show_options(
return error; return error;
} }
STATIC int
linvfs_quotasync(
struct super_block *sb,
int type)
{
struct vfs *vfsp = LINVFS_GET_VFS(sb);
int error;
VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
return -error;
}
STATIC int STATIC int
linvfs_getxstate( linvfs_getxstate(
struct super_block *sb, struct super_block *sb,
@ -868,6 +931,7 @@ STATIC struct super_operations linvfs_sops = {
}; };
STATIC struct quotactl_ops linvfs_qops = { STATIC struct quotactl_ops linvfs_qops = {
.quota_sync = linvfs_quotasync,
.get_xstate = linvfs_getxstate, .get_xstate = linvfs_getxstate,
.set_xstate = linvfs_setxstate, .set_xstate = linvfs_setxstate,
.get_xquota = linvfs_getxquota, .get_xquota = linvfs_getxquota,

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPER_H__ #ifndef __XFS_SUPER_H__
#define __XFS_SUPER_H__ #define __XFS_SUPER_H__
@ -132,6 +118,7 @@ extern void xfs_flush_device(struct xfs_inode *);
extern int xfs_blkdev_get(struct xfs_mount *, const char *, extern int xfs_blkdev_get(struct xfs_mount *, const char *,
struct block_device **); struct block_device **);
extern void xfs_blkdev_put(struct block_device *); extern void xfs_blkdev_put(struct block_device *);
extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
extern struct export_operations linvfs_export_ops; extern struct export_operations linvfs_export_ops;

View file

@ -1,44 +1,26 @@
/* /*
* Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_rw.h"
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
static struct ctl_table_header *xfs_table_header; static struct ctl_table_header *xfs_table_header;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
STATIC int STATIC int
xfs_stats_clear_proc_handler( xfs_stats_clear_proc_handler(

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SYSCTL_H__ #ifndef __XFS_SYSCTL_H__
#define __XFS_SYSCTL_H__ #define __XFS_SYSCTL_H__

View file

@ -1,34 +1,22 @@
/* /*
* Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_VERSION_H__
#define __XFS_VERSION_H__
/* /*
* Dummy file that can contain a timestamp to put into the * Dummy file that can contain a timestamp to put into the
@ -36,9 +24,6 @@
* running * running
*/ */
#ifndef __XFS_VERSION_H__
#define __XFS_VERSION_H__
#define XFS_VERSION_STRING "SGI XFS" #define XFS_VERSION_STRING "SGI XFS"
#endif /* __XFS_VERSION_H__ */ #endif /* __XFS_VERSION_H__ */

View file

@ -1,38 +1,22 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_inum.h" #include "xfs_inum.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_clnt.h" #include "xfs_clnt.h"

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_VFS_H__ #ifndef __XFS_VFS_H__
#define __XFS_VFS_H__ #define __XFS_VFS_H__
@ -95,6 +81,7 @@ typedef enum {
#define VFS_RDONLY 0x0001 /* read-only vfs */ #define VFS_RDONLY 0x0001 /* read-only vfs */
#define VFS_GRPID 0x0002 /* group-ID assigned from directory */ #define VFS_GRPID 0x0002 /* group-ID assigned from directory */
#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
#define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */
#define VFS_END 0x0008 /* max flag */ #define VFS_END 0x0008 /* max flag */
#define SYNC_ATTR 0x0001 /* sync attributes */ #define SYNC_ATTR 0x0001 /* sync attributes */

View file

@ -1,38 +1,22 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
uint64_t vn_generation; /* vnode generation number */ uint64_t vn_generation; /* vnode generation number */
DEFINE_SPINLOCK(vnumber_lock); DEFINE_SPINLOCK(vnumber_lock);
@ -44,7 +28,6 @@ DEFINE_SPINLOCK(vnumber_lock);
#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) #define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
STATIC wait_queue_head_t vsync[NVSYNC]; STATIC wait_queue_head_t vsync[NVSYNC];
void void
vn_init(void) vn_init(void)
{ {
@ -124,6 +107,7 @@ vn_revalidate_core(
inode->i_mtime = vap->va_mtime; inode->i_mtime = vap->va_mtime;
inode->i_ctime = vap->va_ctime; inode->i_ctime = vap->va_ctime;
inode->i_atime = vap->va_atime; inode->i_atime = vap->va_atime;
inode->i_blksize = vap->va_blocksize;
if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
inode->i_flags |= S_IMMUTABLE; inode->i_flags |= S_IMMUTABLE;
else else

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
* *
* Portions Copyright (c) 1989, 1993 * Portions Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -216,11 +202,12 @@ typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
struct xfs_iomap *, int *); struct xfs_iomap *, int *);
typedef int (*vop_reclaim_t)(bhv_desc_t *); typedef int (*vop_reclaim_t)(bhv_desc_t *);
typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int, typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *,
struct cred *); int, struct cred *);
typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int, typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int,
struct cred *); int, struct cred *);
typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *); typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *,
int, struct cred *);
typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
struct attrlist_cursor_kern *, struct cred *); struct attrlist_cursor_kern *, struct cred *);
typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int); typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
@ -565,13 +552,6 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
spin_unlock(&vp->v_lock); spin_unlock(&vp->v_lock);
} }
/*
* Update modify/access/change times on the vnode
*/
#define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
#define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp))
#define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
/* /*
* Dealing with bad inodes * Dealing with bad inodes
*/ */
@ -603,6 +583,7 @@ static inline int VN_BAD(struct vnode *vp)
#define ATTR_LAZY 0x80 /* set/get attributes lazily */ #define ATTR_LAZY 0x80 /* set/get attributes lazily */
#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
/* /*
* Flags to VOP_FSYNC and VOP_RECLAIM. * Flags to VOP_FSYNC and VOP_RECLAIM.

View file

@ -1 +0,0 @@
include $(TOPDIR)/fs/xfs/quota/Makefile-linux-$(VERSION).$(PATCHLEVEL)

View file

@ -1,53 +0,0 @@
#
# 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
# 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/
#
EXTRA_CFLAGS += -I $(TOPDIR)/fs/xfs -I $(TOPDIR)/fs/xfs/linux-2.6
ifeq ($(CONFIG_XFS_DEBUG),y)
EXTRA_CFLAGS += -g -DDEBUG
#EXTRA_CFLAGS += -DQUOTADEBUG
endif
ifeq ($(CONFIG_XFS_TRACE),y)
EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
EXTRA_CFLAGS += -DXFS_VNODE_TRACE
endif
xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \
xfs_dquot_item.o \
xfs_trans_dquot.o \
xfs_qm_syscalls.o \
xfs_qm_bhv.o \
xfs_qm.o
ifeq ($(CONFIG_XFS_QUOTA),y)
xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o
endif

View file

@ -1,39 +1,25 @@
/* /*
* Copyright (c) 2000-2003 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 * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,18 +29,17 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
@ -66,7 +51,6 @@
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_qm.h" #include "xfs_qm.h"
@ -112,7 +96,7 @@ xfs_qm_dqinit(
brandnewdquot = xfs_qm_dqalloc_incore(&dqp); brandnewdquot = xfs_qm_dqalloc_incore(&dqp);
dqp->dq_flags = type; dqp->dq_flags = type;
INT_SET(dqp->q_core.d_id, ARCH_CONVERT, id); dqp->q_core.d_id = cpu_to_be32(id);
dqp->q_mount = mp; dqp->q_mount = mp;
/* /*
@ -194,10 +178,10 @@ xfs_qm_dqinit_core(
/* /*
* Caller has zero'd the entire dquot 'chunk' already. * Caller has zero'd the entire dquot 'chunk' already.
*/ */
INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); d->dd_diskdq.d_version = XFS_DQUOT_VERSION;
INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); d->dd_diskdq.d_id = cpu_to_be32(id);
INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); d->dd_diskdq.d_flags = type;
} }
@ -227,19 +211,13 @@ __xfs_dqtrace_entry(
(void *)(__psint_t)dqp->q_nrefs, (void *)(__psint_t)dqp->q_nrefs,
(void *)(__psint_t)dqp->dq_flags, (void *)(__psint_t)dqp->dq_flags,
(void *)(__psint_t)dqp->q_res_bcount, (void *)(__psint_t)dqp->q_res_bcount,
(void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount),
ARCH_CONVERT), (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount),
(void *)(__psint_t)INT_GET(dqp->q_core.d_icount, (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit),
ARCH_CONVERT), (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit),
(void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit),
ARCH_CONVERT), (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit),
(void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id),
ARCH_CONVERT),
(void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit,
ARCH_CONVERT),
(void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit,
ARCH_CONVERT),
(void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
(void *)(__psint_t)current_pid(), (void *)(__psint_t)current_pid(),
(void *)(__psint_t)ino, (void *)(__psint_t)ino,
(void *)(__psint_t)retaddr, (void *)(__psint_t)retaddr,
@ -264,17 +242,17 @@ xfs_qm_adjust_dqlimits(
ASSERT(d->d_id); ASSERT(d->d_id);
if (q->qi_bsoftlimit && !d->d_blk_softlimit) if (q->qi_bsoftlimit && !d->d_blk_softlimit)
INT_SET(d->d_blk_softlimit, ARCH_CONVERT, q->qi_bsoftlimit); d->d_blk_softlimit = cpu_to_be64(q->qi_bsoftlimit);
if (q->qi_bhardlimit && !d->d_blk_hardlimit) if (q->qi_bhardlimit && !d->d_blk_hardlimit)
INT_SET(d->d_blk_hardlimit, ARCH_CONVERT, q->qi_bhardlimit); d->d_blk_hardlimit = cpu_to_be64(q->qi_bhardlimit);
if (q->qi_isoftlimit && !d->d_ino_softlimit) if (q->qi_isoftlimit && !d->d_ino_softlimit)
INT_SET(d->d_ino_softlimit, ARCH_CONVERT, q->qi_isoftlimit); d->d_ino_softlimit = cpu_to_be64(q->qi_isoftlimit);
if (q->qi_ihardlimit && !d->d_ino_hardlimit) if (q->qi_ihardlimit && !d->d_ino_hardlimit)
INT_SET(d->d_ino_hardlimit, ARCH_CONVERT, q->qi_ihardlimit); d->d_ino_hardlimit = cpu_to_be64(q->qi_ihardlimit);
if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit) if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit)
INT_SET(d->d_rtb_softlimit, ARCH_CONVERT, q->qi_rtbsoftlimit); d->d_rtb_softlimit = cpu_to_be64(q->qi_rtbsoftlimit);
if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit) if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit)
INT_SET(d->d_rtb_hardlimit, ARCH_CONVERT, q->qi_rtbhardlimit); d->d_rtb_hardlimit = cpu_to_be64(q->qi_rtbhardlimit);
} }
/* /*
@ -298,81 +276,81 @@ xfs_qm_adjust_dqtimers(
ASSERT(d->d_id); ASSERT(d->d_id);
#ifdef QUOTADEBUG #ifdef QUOTADEBUG
if (INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)) if (d->d_blk_hardlimit)
ASSERT(INT_GET(d->d_blk_softlimit, ARCH_CONVERT) <= ASSERT(be64_to_cpu(d->d_blk_softlimit) <=
INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)); be64_to_cpu(d->d_blk_hardlimit));
if (INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)) if (d->d_ino_hardlimit)
ASSERT(INT_GET(d->d_ino_softlimit, ARCH_CONVERT) <= ASSERT(be64_to_cpu(d->d_ino_softlimit) <=
INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)); be64_to_cpu(d->d_ino_hardlimit));
if (INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)) if (d->d_rtb_hardlimit)
ASSERT(INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) <= ASSERT(be64_to_cpu(d->d_rtb_softlimit) <=
INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)); be64_to_cpu(d->d_rtb_hardlimit));
#endif #endif
if (!d->d_btimer) { if (!d->d_btimer) {
if ((INT_GET(d->d_blk_softlimit, ARCH_CONVERT) && if ((d->d_blk_softlimit &&
(INT_GET(d->d_bcount, ARCH_CONVERT) >= (be64_to_cpu(d->d_bcount) >=
INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) || be64_to_cpu(d->d_blk_softlimit))) ||
(INT_GET(d->d_blk_hardlimit, ARCH_CONVERT) && (d->d_blk_hardlimit &&
(INT_GET(d->d_bcount, ARCH_CONVERT) >= (be64_to_cpu(d->d_bcount) >=
INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_blk_hardlimit)))) {
INT_SET(d->d_btimer, ARCH_CONVERT, d->d_btimer = cpu_to_be32(get_seconds() +
get_seconds() + XFS_QI_BTIMELIMIT(mp)); XFS_QI_BTIMELIMIT(mp));
} else { } else {
d->d_bwarns = 0; d->d_bwarns = 0;
} }
} else { } else {
if ((!d->d_blk_softlimit || if ((!d->d_blk_softlimit ||
(INT_GET(d->d_bcount, ARCH_CONVERT) < (be64_to_cpu(d->d_bcount) <
INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) && be64_to_cpu(d->d_blk_softlimit))) &&
(!d->d_blk_hardlimit || (!d->d_blk_hardlimit ||
(INT_GET(d->d_bcount, ARCH_CONVERT) < (be64_to_cpu(d->d_bcount) <
INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_blk_hardlimit)))) {
d->d_btimer = 0; d->d_btimer = 0;
} }
} }
if (!d->d_itimer) { if (!d->d_itimer) {
if ((INT_GET(d->d_ino_softlimit, ARCH_CONVERT) && if ((d->d_ino_softlimit &&
(INT_GET(d->d_icount, ARCH_CONVERT) >= (be64_to_cpu(d->d_icount) >=
INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) || be64_to_cpu(d->d_ino_softlimit))) ||
(INT_GET(d->d_ino_hardlimit, ARCH_CONVERT) && (d->d_ino_hardlimit &&
(INT_GET(d->d_icount, ARCH_CONVERT) >= (be64_to_cpu(d->d_icount) >=
INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_ino_hardlimit)))) {
INT_SET(d->d_itimer, ARCH_CONVERT, d->d_itimer = cpu_to_be32(get_seconds() +
get_seconds() + XFS_QI_ITIMELIMIT(mp)); XFS_QI_ITIMELIMIT(mp));
} else { } else {
d->d_iwarns = 0; d->d_iwarns = 0;
} }
} else { } else {
if ((!d->d_ino_softlimit || if ((!d->d_ino_softlimit ||
(INT_GET(d->d_icount, ARCH_CONVERT) < (be64_to_cpu(d->d_icount) <
INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) && be64_to_cpu(d->d_ino_softlimit))) &&
(!d->d_ino_hardlimit || (!d->d_ino_hardlimit ||
(INT_GET(d->d_icount, ARCH_CONVERT) < (be64_to_cpu(d->d_icount) <
INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_ino_hardlimit)))) {
d->d_itimer = 0; d->d_itimer = 0;
} }
} }
if (!d->d_rtbtimer) { if (!d->d_rtbtimer) {
if ((INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) && if ((d->d_rtb_softlimit &&
(INT_GET(d->d_rtbcount, ARCH_CONVERT) >= (be64_to_cpu(d->d_rtbcount) >=
INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) || be64_to_cpu(d->d_rtb_softlimit))) ||
(INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT) && (d->d_rtb_hardlimit &&
(INT_GET(d->d_rtbcount, ARCH_CONVERT) >= (be64_to_cpu(d->d_rtbcount) >=
INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_rtb_hardlimit)))) {
INT_SET(d->d_rtbtimer, ARCH_CONVERT, d->d_rtbtimer = cpu_to_be32(get_seconds() +
get_seconds() + XFS_QI_RTBTIMELIMIT(mp)); XFS_QI_RTBTIMELIMIT(mp));
} else { } else {
d->d_rtbwarns = 0; d->d_rtbwarns = 0;
} }
} else { } else {
if ((!d->d_rtb_softlimit || if ((!d->d_rtb_softlimit ||
(INT_GET(d->d_rtbcount, ARCH_CONVERT) < (be64_to_cpu(d->d_rtbcount) <
INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) && be64_to_cpu(d->d_rtb_softlimit))) &&
(!d->d_rtb_hardlimit || (!d->d_rtb_hardlimit ||
(INT_GET(d->d_rtbcount, ARCH_CONVERT) < (be64_to_cpu(d->d_rtbcount) <
INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { be64_to_cpu(d->d_rtb_hardlimit)))) {
d->d_rtbtimer = 0; d->d_rtbtimer = 0;
} }
} }
@ -490,7 +468,7 @@ xfs_qm_dqalloc(
* Make a chunk of dquots out of this buffer and log * Make a chunk of dquots out of this buffer and log
* the entire thing. * the entire thing.
*/ */
xfs_qm_init_dquot_blk(tp, mp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT), xfs_qm_init_dquot_blk(tp, mp, be32_to_cpu(dqp->q_core.d_id),
dqp->dq_flags & XFS_DQ_ALLTYPES, bp); dqp->dq_flags & XFS_DQ_ALLTYPES, bp);
/* /*
@ -554,7 +532,7 @@ xfs_qm_dqtobp(
xfs_trans_t *tp = (tpp ? *tpp : NULL); xfs_trans_t *tp = (tpp ? *tpp : NULL);
mp = dqp->q_mount; mp = dqp->q_mount;
id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); id = be32_to_cpu(dqp->q_core.d_id);
nmaps = 1; nmaps = 1;
newdquot = B_FALSE; newdquot = B_FALSE;
@ -563,8 +541,7 @@ xfs_qm_dqtobp(
*/ */
if (dqp->q_blkno == (xfs_daddr_t) 0) { if (dqp->q_blkno == (xfs_daddr_t) 0) {
/* We use the id as an index */ /* We use the id as an index */
dqp->q_fileoffset = (xfs_fileoff_t) ((uint)id / dqp->q_fileoffset = (xfs_fileoff_t)id / XFS_QM_DQPERBLK(mp);
XFS_QM_DQPERBLK(mp));
nmaps = 1; nmaps = 1;
quotip = XFS_DQ_TO_QIP(dqp); quotip = XFS_DQ_TO_QIP(dqp);
xfs_ilock(quotip, XFS_ILOCK_SHARED); xfs_ilock(quotip, XFS_ILOCK_SHARED);
@ -694,16 +671,16 @@ xfs_qm_dqread(
/* copy everything from disk dquot to the incore dquot */ /* copy everything from disk dquot to the incore dquot */
memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
xfs_qm_dquot_logitem_init(dqp); xfs_qm_dquot_logitem_init(dqp);
/* /*
* Reservation counters are defined as reservation plus current usage * Reservation counters are defined as reservation plus current usage
* to avoid having to add everytime. * to avoid having to add everytime.
*/ */
dqp->q_res_bcount = INT_GET(ddqp->d_bcount, ARCH_CONVERT); dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
dqp->q_res_icount = INT_GET(ddqp->d_icount, ARCH_CONVERT); dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
dqp->q_res_rtbcount = INT_GET(ddqp->d_rtbcount, ARCH_CONVERT); dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
/* Mark the buf so that this will stay incore a little longer */ /* Mark the buf so that this will stay incore a little longer */
XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF); XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF);
@ -829,7 +806,7 @@ xfs_qm_dqlookup(
* dqlock to look at the id field of the dquot, since the * dqlock to look at the id field of the dquot, since the
* id can't be modified without the hashlock anyway. * id can't be modified without the hashlock anyway.
*/ */
if (INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id && dqp->q_mount == mp) { if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) {
xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP");
/* /*
* All in core dquots must be on the dqlist of mp * All in core dquots must be on the dqlist of mp
@ -860,7 +837,7 @@ xfs_qm_dqlookup(
* id couldn't have changed; we had the hashlock all * id couldn't have changed; we had the hashlock all
* along * along
*/ */
ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
if (flist_locked) { if (flist_locked) {
if (dqp->q_nrefs != 0) { if (dqp->q_nrefs != 0) {
@ -1282,7 +1259,7 @@ xfs_qm_dqflush(
return (error); return (error);
} }
if (xfs_qm_dqcheck(&dqp->q_core, INT_GET(ddqp->d_id, ARCH_CONVERT), if (xfs_qm_dqcheck(&dqp->q_core, be32_to_cpu(ddqp->d_id),
0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) { 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) {
xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE); xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE);
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
@ -1435,8 +1412,8 @@ xfs_dqlock2(
{ {
if (d1 && d2) { if (d1 && d2) {
ASSERT(d1 != d2); ASSERT(d1 != d2);
if (INT_GET(d1->q_core.d_id, ARCH_CONVERT) > if (be32_to_cpu(d1->q_core.d_id) >
INT_GET(d2->q_core.d_id, ARCH_CONVERT)) { be32_to_cpu(d2->q_core.d_id)) {
xfs_dqlock(d2); xfs_dqlock(d2);
xfs_dqlock(d1); xfs_dqlock(d1);
} else { } else {
@ -1558,33 +1535,33 @@ xfs_qm_dqprint(xfs_dquot_t *dqp)
{ {
cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------");
cmn_err(CE_DEBUG, "---- dquotID = %d", cmn_err(CE_DEBUG, "---- dquotID = %d",
(int)INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); (int)be32_to_cpu(dqp->q_core.d_id));
cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp));
cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount);
cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno);
cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset);
cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)",
INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_blk_hardlimit),
(int) INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_blk_hardlimit));
cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)",
INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_blk_softlimit),
(int)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_blk_softlimit));
cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)",
INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_ino_hardlimit),
(int)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_ino_hardlimit));
cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)",
INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_ino_softlimit),
(int)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_ino_softlimit));
cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)",
INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_bcount),
(int)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_bcount));
cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)",
INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_icount),
(int)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); (int)be64_to_cpu(dqp->q_core.d_icount));
cmn_err(CE_DEBUG, "---- btimer = %d", cmn_err(CE_DEBUG, "---- btimer = %d",
(int)INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT)); (int)be32_to_cpu(dqp->q_core.d_btimer));
cmn_err(CE_DEBUG, "---- itimer = %d", cmn_err(CE_DEBUG, "---- itimer = %d",
(int)INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT)); (int)be32_to_cpu(dqp->q_core.d_itimer));
cmn_err(CE_DEBUG, "---------------------------"); cmn_err(CE_DEBUG, "---------------------------");
} }
#endif #endif

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_H__ #ifndef __XFS_DQUOT_H__
#define __XFS_DQUOT_H__ #define __XFS_DQUOT_H__

View file

@ -1,39 +1,25 @@
/* /*
* Copyright (c) 2000-2003 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 * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,18 +29,17 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_itable.h"
@ -65,10 +50,8 @@
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_qm.h" #include "xfs_qm.h"
/* /*
* returns the number of iovecs needed to log the given dquot item. * returns the number of iovecs needed to log the given dquot item.
*/ */
@ -467,7 +450,7 @@ xfs_qm_dquot_logitem_init(
lp->qli_item.li_mountp = dqp->q_mount; lp->qli_item.li_mountp = dqp->q_mount;
lp->qli_dquot = dqp; lp->qli_dquot = dqp;
lp->qli_format.qlf_type = XFS_LI_DQUOT; lp->qli_format.qlf_type = XFS_LI_DQUOT;
lp->qli_format.qlf_id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id);
lp->qli_format.qlf_blkno = dqp->q_blkno; lp->qli_format.qlf_blkno = dqp->q_blkno;
lp->qli_format.qlf_len = 1; lp->qli_format.qlf_len = 1;
/* /*

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 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 * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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__ #ifndef __XFS_DQUOT_ITEM_H__
#define __XFS_DQUOT_ITEM_H__ #define __XFS_DQUOT_ITEM_H__

View file

@ -1,39 +1,25 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_clnt.h" #include "xfs_clnt.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
@ -44,21 +30,20 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bmap.h" #include "xfs_btree.h"
#include "xfs_bit.h" #include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h" #include "xfs_bmap.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
@ -67,7 +52,6 @@
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_utils.h" #include "xfs_utils.h"
#include "xfs_qm.h" #include "xfs_qm.h"
/* /*
@ -76,8 +60,9 @@
* quota functionality, including maintaining the freelist and hash * quota functionality, including maintaining the freelist and hash
* tables of dquots. * tables of dquots.
*/ */
mutex_t xfs_Gqm_lock; mutex_t xfs_Gqm_lock;
struct xfs_qm *xfs_Gqm; struct xfs_qm *xfs_Gqm;
uint ndquot;
kmem_zone_t *qm_dqzone; kmem_zone_t *qm_dqzone;
kmem_zone_t *qm_dqtrxzone; kmem_zone_t *qm_dqtrxzone;
@ -107,10 +92,10 @@ extern mutex_t qcheck_lock;
for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \ for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \
cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \ cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \
"bcnt = %d, icnt = %d, refs = %d", \ "bcnt = %d, icnt = %d, refs = %d", \
++i, (int) INT_GET(dqp->q_core.d_id, ARCH_CONVERT), \ ++i, (int) be32_to_cpu(dqp->q_core.d_id), \
DQFLAGTO_TYPESTR(dqp), \ DQFLAGTO_TYPESTR(dqp), \
(int) INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), \ (int) be64_to_cpu(dqp->q_core.d_bcount), \
(int) INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), \ (int) be64_to_cpu(dqp->q_core.d_icount), \
(int) dqp->q_nrefs); } \ (int) dqp->q_nrefs); } \
} }
#else #else
@ -124,25 +109,25 @@ extern mutex_t qcheck_lock;
STATIC struct xfs_qm * STATIC struct xfs_qm *
xfs_Gqm_init(void) xfs_Gqm_init(void)
{ {
xfs_qm_t *xqm; xfs_dqhash_t *udqhash, *gdqhash;
int hsize, i; xfs_qm_t *xqm;
uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL;
xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
ASSERT(xqm);
/* /*
* Initialize the dquot hash tables. * Initialize the dquot hash tables.
*/ */
hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ? hsize = XFS_QM_HASHSIZE_HIGH;
XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH; while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) {
xqm->qm_dqhashmask = hsize - 1; if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW)
flags = KM_SLEEP;
}
gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP);
ndquot = hsize << 8;
xqm->qm_usr_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
sizeof(xfs_dqhash_t), xqm->qm_dqhashmask = hsize - 1;
KM_SLEEP); xqm->qm_usr_dqhtable = udqhash;
xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * xqm->qm_grp_dqhtable = gdqhash;
sizeof(xfs_dqhash_t),
KM_SLEEP);
ASSERT(xqm->qm_usr_dqhtable != NULL); ASSERT(xqm->qm_usr_dqhtable != NULL);
ASSERT(xqm->qm_grp_dqhtable != NULL); ASSERT(xqm->qm_grp_dqhtable != NULL);
@ -743,7 +728,7 @@ xfs_qm_dqattach_one(
*/ */
if (udqhint && if (udqhint &&
(dqp = udqhint->q_gdquot) && (dqp = udqhint->q_gdquot) &&
(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id)) { (be32_to_cpu(dqp->q_core.d_id) == id)) {
ASSERT(XFS_DQ_IS_LOCKED(udqhint)); ASSERT(XFS_DQ_IS_LOCKED(udqhint));
xfs_dqlock(dqp); xfs_dqlock(dqp);
XFS_DQHOLD(dqp); XFS_DQHOLD(dqp);
@ -1213,42 +1198,24 @@ xfs_qm_init_quotainfo(
* a user or group before he or she can not perform any * a user or group before he or she can not perform any
* more writing. If it is zero, a default is used. * more writing. If it is zero, a default is used.
*/ */
qinf->qi_btimelimit = qinf->qi_btimelimit = ddqp->d_btimer ?
INT_GET(ddqp->d_btimer, ARCH_CONVERT) ? be32_to_cpu(ddqp->d_btimer) : XFS_QM_BTIMELIMIT;
INT_GET(ddqp->d_btimer, ARCH_CONVERT) : qinf->qi_itimelimit = ddqp->d_itimer ?
XFS_QM_BTIMELIMIT; be32_to_cpu(ddqp->d_itimer) : XFS_QM_ITIMELIMIT;
qinf->qi_itimelimit = qinf->qi_rtbtimelimit = ddqp->d_rtbtimer ?
INT_GET(ddqp->d_itimer, ARCH_CONVERT) ? be32_to_cpu(ddqp->d_rtbtimer) : XFS_QM_RTBTIMELIMIT;
INT_GET(ddqp->d_itimer, ARCH_CONVERT) : qinf->qi_bwarnlimit = ddqp->d_bwarns ?
XFS_QM_ITIMELIMIT; be16_to_cpu(ddqp->d_bwarns) : XFS_QM_BWARNLIMIT;
qinf->qi_rtbtimelimit = qinf->qi_iwarnlimit = ddqp->d_iwarns ?
INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) ? be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT;
INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) : qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ?
XFS_QM_RTBTIMELIMIT; be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT;
qinf->qi_bwarnlimit = qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
INT_GET(ddqp->d_bwarns, ARCH_CONVERT) ? qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
INT_GET(ddqp->d_bwarns, ARCH_CONVERT) : qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
XFS_QM_BWARNLIMIT; qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
qinf->qi_iwarnlimit = qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ? qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
INT_GET(ddqp->d_iwarns, ARCH_CONVERT) :
XFS_QM_IWARNLIMIT;
qinf->qi_rtbwarnlimit =
INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) ?
INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) :
XFS_QM_RTBWARNLIMIT;
qinf->qi_bhardlimit =
INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT);
qinf->qi_bsoftlimit =
INT_GET(ddqp->d_blk_softlimit, ARCH_CONVERT);
qinf->qi_ihardlimit =
INT_GET(ddqp->d_ino_hardlimit, ARCH_CONVERT);
qinf->qi_isoftlimit =
INT_GET(ddqp->d_ino_softlimit, ARCH_CONVERT);
qinf->qi_rtbhardlimit =
INT_GET(ddqp->d_rtb_hardlimit, ARCH_CONVERT);
qinf->qi_rtbsoftlimit =
INT_GET(ddqp->d_rtb_softlimit, ARCH_CONVERT);
/* /*
* We sent the XFS_QMOPT_DQSUSER flag to dqget because * We sent the XFS_QMOPT_DQSUSER flag to dqget because
@ -1527,15 +1494,15 @@ xfs_qm_reset_dqcounts(
*/ */
(void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR, (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR,
"xfs_quotacheck"); "xfs_quotacheck");
INT_SET(ddq->d_bcount, ARCH_CONVERT, 0ULL); ddq->d_bcount = 0;
INT_SET(ddq->d_icount, ARCH_CONVERT, 0ULL); ddq->d_icount = 0;
INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL); ddq->d_rtbcount = 0;
INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0); ddq->d_btimer = 0;
INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0); ddq->d_itimer = 0;
INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, (time_t)0); ddq->d_rtbtimer = 0;
INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL); ddq->d_bwarns = 0;
INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL); ddq->d_iwarns = 0;
INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, 0UL); ddq->d_rtbwarns = 0;
ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
} }
@ -1708,14 +1675,14 @@ xfs_qm_quotacheck_dqadjust(
* Adjust the inode count and the block count to reflect this inode's * Adjust the inode count and the block count to reflect this inode's
* resource usage. * resource usage.
*/ */
INT_MOD(dqp->q_core.d_icount, ARCH_CONVERT, +1); be64_add(&dqp->q_core.d_icount, 1);
dqp->q_res_icount++; dqp->q_res_icount++;
if (nblks) { if (nblks) {
INT_MOD(dqp->q_core.d_bcount, ARCH_CONVERT, nblks); be64_add(&dqp->q_core.d_bcount, nblks);
dqp->q_res_bcount += nblks; dqp->q_res_bcount += nblks;
} }
if (rtblks) { if (rtblks) {
INT_MOD(dqp->q_core.d_rtbcount, ARCH_CONVERT, rtblks); be64_add(&dqp->q_core.d_rtbcount, rtblks);
dqp->q_res_rtbcount += rtblks; dqp->q_res_rtbcount += rtblks;
} }
@ -2202,7 +2169,7 @@ xfs_qm_shake_freelist(
xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
#ifdef QUOTADEBUG #ifdef QUOTADEBUG
cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n",
dqp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); dqp, be32_to_cpu(dqp->q_core.d_id));
#endif #endif
ASSERT(dqp->q_nrefs == 0); ASSERT(dqp->q_nrefs == 0);
nextdqp = dqp->dq_flnext; nextdqp = dqp->dq_flnext;
@ -2670,7 +2637,7 @@ xfs_qm_vop_chown_reserve(
XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
if (XFS_IS_UQUOTA_ON(mp) && udqp && if (XFS_IS_UQUOTA_ON(mp) && udqp &&
ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) { ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) {
delblksudq = udqp; delblksudq = udqp;
/* /*
* If there are delayed allocation blocks, then we have to * If there are delayed allocation blocks, then we have to
@ -2683,10 +2650,10 @@ xfs_qm_vop_chown_reserve(
} }
} }
if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
if ((XFS_IS_GQUOTA_ON(ip->i_mount) && ip->i_d.di_gid != if ((XFS_IS_GQUOTA_ON(ip->i_mount) &&
INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) || ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) ||
(XFS_IS_PQUOTA_ON(ip->i_mount) && ip->i_d.di_projid != (XFS_IS_PQUOTA_ON(ip->i_mount) &&
INT_GET(gdqp->q_core.d_id, ARCH_CONVERT))) { ip->i_d.di_projid != be32_to_cpu(gdqp->q_core.d_id))) {
delblksgdq = gdqp; delblksgdq = gdqp;
if (delblks) { if (delblks) {
ASSERT(ip->i_gdquot); ASSERT(ip->i_gdquot);
@ -2776,7 +2743,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
xfs_dqunlock(udqp); xfs_dqunlock(udqp);
ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_udquot == NULL);
ip->i_udquot = udqp; ip->i_udquot = udqp;
ASSERT(ip->i_d.di_uid == INT_GET(udqp->q_core.d_id, ARCH_CONVERT)); ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));
xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
if (gdqp) { if (gdqp) {
@ -2785,7 +2752,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
xfs_dqunlock(gdqp); xfs_dqunlock(gdqp);
ASSERT(ip->i_gdquot == NULL); ASSERT(ip->i_gdquot == NULL);
ip->i_gdquot = gdqp; ip->i_gdquot = gdqp;
ASSERT(ip->i_d.di_gid == INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)); ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id));
xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_QM_H__ #ifndef __XFS_QM_H__
#define __XFS_QM_H__ #define __XFS_QM_H__
@ -40,6 +26,7 @@
struct xfs_qm; struct xfs_qm;
struct xfs_inode; struct xfs_inode;
extern uint ndquot;
extern mutex_t xfs_Gqm_lock; extern mutex_t xfs_Gqm_lock;
extern struct xfs_qm *xfs_Gqm; extern struct xfs_qm *xfs_Gqm;
extern kmem_zone_t *qm_dqzone; extern kmem_zone_t *qm_dqzone;
@ -65,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone;
/* /*
* Dquot hashtable constants/threshold values. * Dquot hashtable constants/threshold values.
*/ */
#define XFS_QM_NCSIZE_THRESHOLD 5000 #define XFS_QM_HASHSIZE_LOW (NBPP / sizeof(xfs_dqhash_t))
#define XFS_QM_HASHSIZE_LOW 32 #define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t))
#define XFS_QM_HASHSIZE_HIGH 64
/* /*
* We output a cmn_err when quotachecking a quota file with more than * We output a cmn_err when quotachecking a quota file with more than

View file

@ -1,70 +1,55 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_clnt.h" #include "xfs_clnt.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_btree.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
#include "xfs_mac.h" #include "xfs_mac.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_qm.h" #include "xfs_qm.h"
#define MNTOPT_QUOTA "quota" /* disk quotas (user) */ #define MNTOPT_QUOTA "quota" /* disk quotas (user) */

View file

@ -1,69 +1,54 @@
/* /*
* Copyright (c) 2000-2003 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 * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
#include "xfs_mac.h" #include "xfs_mac.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_qm.h" #include "xfs_qm.h"
struct xqmstats xqmstats; struct xqmstats xqmstats;

View file

@ -1,38 +1,23 @@
/* /*
* Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2002 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_QM_STATS_H__ #ifndef __XFS_QM_STATS_H__
#define __XFS_QM_STATS_H__ #define __XFS_QM_STATS_H__
#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF) #if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
/* /*

View file

@ -1,62 +1,48 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
@ -64,7 +50,6 @@
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_utils.h" #include "xfs_utils.h"
#include "xfs_qm.h" #include "xfs_qm.h"
#ifdef DEBUG #ifdef DEBUG
@ -109,10 +94,7 @@ xfs_qm_quotactl(
vfsp = bhvtovfs(bdp); vfsp = bhvtovfs(bdp);
mp = XFS_VFSTOM(vfsp); mp = XFS_VFSTOM(vfsp);
if (addr == NULL && cmd != Q_SYNC) ASSERT(addr != NULL || cmd == Q_XQUOTASYNC);
return XFS_ERROR(EINVAL);
if (id < 0 && cmd != Q_SYNC)
return XFS_ERROR(EINVAL);
/* /*
* The following commands are valid even when quotaoff. * The following commands are valid even when quotaoff.
@ -122,7 +104,7 @@ xfs_qm_quotactl(
/* /*
* Truncate quota files. quota must be off. * Truncate quota files. quota must be off.
*/ */
if (XFS_IS_QUOTA_ON(mp) || addr == NULL) if (XFS_IS_QUOTA_ON(mp))
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
if (vfsp->vfs_flag & VFS_RDONLY) if (vfsp->vfs_flag & VFS_RDONLY)
return XFS_ERROR(EROFS); return XFS_ERROR(EROFS);
@ -140,8 +122,6 @@ xfs_qm_quotactl(
* QUOTAON - enabling quota enforcement. * QUOTAON - enabling quota enforcement.
* Quota accounting must be turned on at mount time. * Quota accounting must be turned on at mount time.
*/ */
if (addr == NULL)
return XFS_ERROR(EINVAL);
if (vfsp->vfs_flag & VFS_RDONLY) if (vfsp->vfs_flag & VFS_RDONLY)
return XFS_ERROR(EROFS); return XFS_ERROR(EROFS);
return (xfs_qm_scall_quotaon(mp, return (xfs_qm_scall_quotaon(mp,
@ -152,6 +132,9 @@ xfs_qm_quotactl(
return XFS_ERROR(EROFS); return XFS_ERROR(EROFS);
break; break;
case Q_XQUOTASYNC:
return (xfs_sync_inodes(mp, SYNC_DELWRI, 0, NULL));
default: default:
break; break;
} }
@ -655,13 +638,13 @@ xfs_qm_scall_setqlim(
*/ */
hard = (newlim->d_fieldmask & FS_DQ_BHARD) ? hard = (newlim->d_fieldmask & FS_DQ_BHARD) ?
(xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) : (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) :
INT_GET(ddq->d_blk_hardlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_blk_hardlimit);
soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ? soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ?
(xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) : (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) :
INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_blk_softlimit);
if (hard == 0 || hard >= soft) { if (hard == 0 || hard >= soft) {
INT_SET(ddq->d_blk_hardlimit, ARCH_CONVERT, hard); ddq->d_blk_hardlimit = cpu_to_be64(hard);
INT_SET(ddq->d_blk_softlimit, ARCH_CONVERT, soft); ddq->d_blk_softlimit = cpu_to_be64(soft);
if (id == 0) { if (id == 0) {
mp->m_quotainfo->qi_bhardlimit = hard; mp->m_quotainfo->qi_bhardlimit = hard;
mp->m_quotainfo->qi_bsoftlimit = soft; mp->m_quotainfo->qi_bsoftlimit = soft;
@ -671,13 +654,13 @@ xfs_qm_scall_setqlim(
} }
hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ?
(xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) :
INT_GET(ddq->d_rtb_hardlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_rtb_hardlimit);
soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ? soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ?
(xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) : (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) :
INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_rtb_softlimit);
if (hard == 0 || hard >= soft) { if (hard == 0 || hard >= soft) {
INT_SET(ddq->d_rtb_hardlimit, ARCH_CONVERT, hard); ddq->d_rtb_hardlimit = cpu_to_be64(hard);
INT_SET(ddq->d_rtb_softlimit, ARCH_CONVERT, soft); ddq->d_rtb_softlimit = cpu_to_be64(soft);
if (id == 0) { if (id == 0) {
mp->m_quotainfo->qi_rtbhardlimit = hard; mp->m_quotainfo->qi_rtbhardlimit = hard;
mp->m_quotainfo->qi_rtbsoftlimit = soft; mp->m_quotainfo->qi_rtbsoftlimit = soft;
@ -688,13 +671,13 @@ xfs_qm_scall_setqlim(
hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? hard = (newlim->d_fieldmask & FS_DQ_IHARD) ?
(xfs_qcnt_t) newlim->d_ino_hardlimit : (xfs_qcnt_t) newlim->d_ino_hardlimit :
INT_GET(ddq->d_ino_hardlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_ino_hardlimit);
soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ? soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ?
(xfs_qcnt_t) newlim->d_ino_softlimit : (xfs_qcnt_t) newlim->d_ino_softlimit :
INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT); be64_to_cpu(ddq->d_ino_softlimit);
if (hard == 0 || hard >= soft) { if (hard == 0 || hard >= soft) {
INT_SET(ddq->d_ino_hardlimit, ARCH_CONVERT, hard); ddq->d_ino_hardlimit = cpu_to_be64(hard);
INT_SET(ddq->d_ino_softlimit, ARCH_CONVERT, soft); ddq->d_ino_softlimit = cpu_to_be64(soft);
if (id == 0) { if (id == 0) {
mp->m_quotainfo->qi_ihardlimit = hard; mp->m_quotainfo->qi_ihardlimit = hard;
mp->m_quotainfo->qi_isoftlimit = soft; mp->m_quotainfo->qi_isoftlimit = soft;
@ -707,11 +690,11 @@ xfs_qm_scall_setqlim(
* Update warnings counter(s) if requested * Update warnings counter(s) if requested
*/ */
if (newlim->d_fieldmask & FS_DQ_BWARNS) if (newlim->d_fieldmask & FS_DQ_BWARNS)
INT_SET(ddq->d_bwarns, ARCH_CONVERT, newlim->d_bwarns); ddq->d_bwarns = cpu_to_be16(newlim->d_bwarns);
if (newlim->d_fieldmask & FS_DQ_IWARNS) if (newlim->d_fieldmask & FS_DQ_IWARNS)
INT_SET(ddq->d_iwarns, ARCH_CONVERT, newlim->d_iwarns); ddq->d_iwarns = cpu_to_be16(newlim->d_iwarns);
if (newlim->d_fieldmask & FS_DQ_RTBWARNS) if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, newlim->d_rtbwarns); ddq->d_rtbwarns = cpu_to_be16(newlim->d_rtbwarns);
if (id == 0) { if (id == 0) {
/* /*
@ -723,15 +706,15 @@ xfs_qm_scall_setqlim(
*/ */
if (newlim->d_fieldmask & FS_DQ_BTIMER) { if (newlim->d_fieldmask & FS_DQ_BTIMER) {
mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; mp->m_quotainfo->qi_btimelimit = newlim->d_btimer;
INT_SET(ddq->d_btimer, ARCH_CONVERT, newlim->d_btimer); ddq->d_btimer = cpu_to_be32(newlim->d_btimer);
} }
if (newlim->d_fieldmask & FS_DQ_ITIMER) { if (newlim->d_fieldmask & FS_DQ_ITIMER) {
mp->m_quotainfo->qi_itimelimit = newlim->d_itimer; mp->m_quotainfo->qi_itimelimit = newlim->d_itimer;
INT_SET(ddq->d_itimer, ARCH_CONVERT, newlim->d_itimer); ddq->d_itimer = cpu_to_be32(newlim->d_itimer);
} }
if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { if (newlim->d_fieldmask & FS_DQ_RTBTIMER) {
mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer;
INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer); ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer);
} }
if (newlim->d_fieldmask & FS_DQ_BWARNS) if (newlim->d_fieldmask & FS_DQ_BWARNS)
mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns; mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns;
@ -902,33 +885,27 @@ xfs_qm_export_dquot(
{ {
memset(dst, 0, sizeof(*dst)); memset(dst, 0, sizeof(*dst));
dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */ dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */
dst->d_flags = dst->d_flags = xfs_qm_export_qtype_flags(src->d_flags);
xfs_qm_export_qtype_flags(INT_GET(src->d_flags, ARCH_CONVERT)); dst->d_id = be32_to_cpu(src->d_id);
dst->d_id = INT_GET(src->d_id, ARCH_CONVERT); dst->d_blk_hardlimit =
dst->d_blk_hardlimit = (__uint64_t) XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_hardlimit));
XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_hardlimit, ARCH_CONVERT)); dst->d_blk_softlimit =
dst->d_blk_softlimit = (__uint64_t) XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_softlimit));
XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_softlimit, ARCH_CONVERT)); dst->d_ino_hardlimit = be64_to_cpu(src->d_ino_hardlimit);
dst->d_ino_hardlimit = (__uint64_t) dst->d_ino_softlimit = be64_to_cpu(src->d_ino_softlimit);
INT_GET(src->d_ino_hardlimit, ARCH_CONVERT); dst->d_bcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_bcount));
dst->d_ino_softlimit = (__uint64_t) dst->d_icount = be64_to_cpu(src->d_icount);
INT_GET(src->d_ino_softlimit, ARCH_CONVERT); dst->d_btimer = be32_to_cpu(src->d_btimer);
dst->d_bcount = (__uint64_t) dst->d_itimer = be32_to_cpu(src->d_itimer);
XFS_FSB_TO_BB(mp, INT_GET(src->d_bcount, ARCH_CONVERT)); dst->d_iwarns = be16_to_cpu(src->d_iwarns);
dst->d_icount = (__uint64_t) INT_GET(src->d_icount, ARCH_CONVERT); dst->d_bwarns = be16_to_cpu(src->d_bwarns);
dst->d_btimer = (__uint32_t) INT_GET(src->d_btimer, ARCH_CONVERT); dst->d_rtb_hardlimit =
dst->d_itimer = (__uint32_t) INT_GET(src->d_itimer, ARCH_CONVERT); XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_hardlimit));
dst->d_iwarns = INT_GET(src->d_iwarns, ARCH_CONVERT); dst->d_rtb_softlimit =
dst->d_bwarns = INT_GET(src->d_bwarns, ARCH_CONVERT); XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_softlimit));
dst->d_rtbcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtbcount));
dst->d_rtb_hardlimit = (__uint64_t) dst->d_rtbtimer = be32_to_cpu(src->d_rtbtimer);
XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_hardlimit, ARCH_CONVERT)); dst->d_rtbwarns = be16_to_cpu(src->d_rtbwarns);
dst->d_rtb_softlimit = (__uint64_t)
XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_softlimit, ARCH_CONVERT));
dst->d_rtbcount = (__uint64_t)
XFS_FSB_TO_BB(mp, INT_GET(src->d_rtbcount, ARCH_CONVERT));
dst->d_rtbtimer = (__uint32_t) INT_GET(src->d_rtbtimer, ARCH_CONVERT);
dst->d_rtbwarns = INT_GET(src->d_rtbwarns, ARCH_CONVERT);
/* /*
* Internally, we don't reset all the timers when quota enforcement * Internally, we don't reset all the timers when quota enforcement
@ -1222,10 +1199,10 @@ xfs_qm_dqtest_failed(
qmtest_nfails++; qmtest_nfails++;
if (error) if (error)
cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s",
INT_GET(d->d_id, ARCH_CONVERT), error, reason); d->d_id, error, reason);
else else
cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]",
INT_GET(d->d_id, ARCH_CONVERT), reason, (int)a, (int)b); d->d_id, reason, (int)a, (int)b);
xfs_qm_dqtest_print(d); xfs_qm_dqtest_print(d);
if (dqp) if (dqp)
xfs_qm_dqprint(dqp); xfs_qm_dqprint(dqp);
@ -1237,21 +1214,21 @@ xfs_dqtest_cmp2(
xfs_dquot_t *dqp) xfs_dquot_t *dqp)
{ {
int err = 0; int err = 0;
if (INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) != d->d_icount) { if (be64_to_cpu(dqp->q_core.d_icount) != d->d_icount) {
xfs_qm_dqtest_failed(d, dqp, "icount mismatch", xfs_qm_dqtest_failed(d, dqp, "icount mismatch",
INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_icount),
d->d_icount, 0); d->d_icount, 0);
err++; err++;
} }
if (INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) != d->d_bcount) { if (be64_to_cpu(dqp->q_core.d_bcount) != d->d_bcount) {
xfs_qm_dqtest_failed(d, dqp, "bcount mismatch", xfs_qm_dqtest_failed(d, dqp, "bcount mismatch",
INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), be64_to_cpu(dqp->q_core.d_bcount),
d->d_bcount, 0); d->d_bcount, 0);
err++; err++;
} }
if (INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT) && if (dqp->q_core.d_blk_softlimit &&
INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) >= be64_to_cpu(dqp->q_core.d_bcount) >=
INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)) { be64_to_cpu(dqp->q_core.d_blk_softlimit)) {
if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { if (!dqp->q_core.d_btimer && dqp->q_core.d_id) {
cmn_err(CE_DEBUG, cmn_err(CE_DEBUG,
"%d [%s] [0x%p] BLK TIMER NOT STARTED", "%d [%s] [0x%p] BLK TIMER NOT STARTED",
@ -1259,9 +1236,9 @@ xfs_dqtest_cmp2(
err++; err++;
} }
} }
if (INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT) && if (dqp->q_core.d_ino_softlimit &&
INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >= be64_to_cpu(dqp->q_core.d_icount) >=
INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)) { be64_to_cpu(dqp->q_core.d_ino_softlimit)) {
if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { if (!dqp->q_core.d_itimer && dqp->q_core.d_id) {
cmn_err(CE_DEBUG, cmn_err(CE_DEBUG,
"%d [%s] [0x%p] INO TIMER NOT STARTED", "%d [%s] [0x%p] INO TIMER NOT STARTED",

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 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 * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_QUOTA_PRIV_H__ #ifndef __XFS_QUOTA_PRIV_H__
#define __XFS_QUOTA_PRIV_H__ #define __XFS_QUOTA_PRIV_H__

View file

@ -1,39 +1,25 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,21 +29,20 @@
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h" #include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_btree.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_bit.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_itable.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_cap.h" #include "xfs_cap.h"
@ -65,7 +50,6 @@
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_qm.h" #include "xfs_qm.h"
STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *);
@ -429,25 +413,25 @@ xfs_trans_apply_dquot_deltas(
qtrx->qt_delrtb_delta; qtrx->qt_delrtb_delta;
#ifdef QUOTADEBUG #ifdef QUOTADEBUG
if (totalbdelta < 0) if (totalbdelta < 0)
ASSERT(INT_GET(d->d_bcount, ARCH_CONVERT) >= ASSERT(be64_to_cpu(d->d_bcount) >=
(xfs_qcnt_t) -totalbdelta); (xfs_qcnt_t) -totalbdelta);
if (totalrtbdelta < 0) if (totalrtbdelta < 0)
ASSERT(INT_GET(d->d_rtbcount, ARCH_CONVERT) >= ASSERT(be64_to_cpu(d->d_rtbcount) >=
(xfs_qcnt_t) -totalrtbdelta); (xfs_qcnt_t) -totalrtbdelta);
if (qtrx->qt_icount_delta < 0) if (qtrx->qt_icount_delta < 0)
ASSERT(INT_GET(d->d_icount, ARCH_CONVERT) >= ASSERT(be64_to_cpu(d->d_icount) >=
(xfs_qcnt_t) -qtrx->qt_icount_delta); (xfs_qcnt_t) -qtrx->qt_icount_delta);
#endif #endif
if (totalbdelta) if (totalbdelta)
INT_MOD(d->d_bcount, ARCH_CONVERT, (xfs_qcnt_t)totalbdelta); be64_add(&d->d_bcount, (xfs_qcnt_t)totalbdelta);
if (qtrx->qt_icount_delta) if (qtrx->qt_icount_delta)
INT_MOD(d->d_icount, ARCH_CONVERT, (xfs_qcnt_t)qtrx->qt_icount_delta); be64_add(&d->d_icount, (xfs_qcnt_t)qtrx->qt_icount_delta);
if (totalrtbdelta) if (totalrtbdelta)
INT_MOD(d->d_rtbcount, ARCH_CONVERT, (xfs_qcnt_t)totalrtbdelta); be64_add(&d->d_rtbcount, (xfs_qcnt_t)totalrtbdelta);
/* /*
* Get any default limits in use. * Get any default limits in use.
@ -531,11 +515,11 @@ xfs_trans_apply_dquot_deltas(
} }
ASSERT(dqp->q_res_bcount >= ASSERT(dqp->q_res_bcount >=
INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); be64_to_cpu(dqp->q_core.d_bcount));
ASSERT(dqp->q_res_icount >= ASSERT(dqp->q_res_icount >=
INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); be64_to_cpu(dqp->q_core.d_icount));
ASSERT(dqp->q_res_rtbcount >= ASSERT(dqp->q_res_rtbcount >=
INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); be64_to_cpu(dqp->q_core.d_rtbcount));
} }
/* /*
* Do the group quotas next * Do the group quotas next
@ -642,26 +626,26 @@ xfs_trans_dqresv(
} }
ASSERT(XFS_DQ_IS_LOCKED(dqp)); ASSERT(XFS_DQ_IS_LOCKED(dqp));
if (flags & XFS_TRANS_DQ_RES_BLKS) { if (flags & XFS_TRANS_DQ_RES_BLKS) {
hardlimit = INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT); hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);
if (!hardlimit) if (!hardlimit)
hardlimit = q->qi_bhardlimit; hardlimit = q->qi_bhardlimit;
softlimit = INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT); softlimit = be64_to_cpu(dqp->q_core.d_blk_softlimit);
if (!softlimit) if (!softlimit)
softlimit = q->qi_bsoftlimit; softlimit = q->qi_bsoftlimit;
timer = INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT); timer = be32_to_cpu(dqp->q_core.d_btimer);
warns = INT_GET(dqp->q_core.d_bwarns, ARCH_CONVERT); warns = be16_to_cpu(dqp->q_core.d_bwarns);
warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount); warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount);
resbcountp = &dqp->q_res_bcount; resbcountp = &dqp->q_res_bcount;
} else { } else {
ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
hardlimit = INT_GET(dqp->q_core.d_rtb_hardlimit, ARCH_CONVERT); hardlimit = be64_to_cpu(dqp->q_core.d_rtb_hardlimit);
if (!hardlimit) if (!hardlimit)
hardlimit = q->qi_rtbhardlimit; hardlimit = q->qi_rtbhardlimit;
softlimit = INT_GET(dqp->q_core.d_rtb_softlimit, ARCH_CONVERT); softlimit = be64_to_cpu(dqp->q_core.d_rtb_softlimit);
if (!softlimit) if (!softlimit)
softlimit = q->qi_rtbsoftlimit; softlimit = q->qi_rtbsoftlimit;
timer = INT_GET(dqp->q_core.d_rtbtimer, ARCH_CONVERT); timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
warns = INT_GET(dqp->q_core.d_rtbwarns, ARCH_CONVERT); warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount);
resbcountp = &dqp->q_res_rtbcount; resbcountp = &dqp->q_res_rtbcount;
} }
@ -700,16 +684,14 @@ xfs_trans_dqresv(
} }
} }
if (ninos > 0) { if (ninos > 0) {
count = INT_GET(dqp->q_core.d_icount, ARCH_CONVERT); count = be64_to_cpu(dqp->q_core.d_icount);
timer = INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT); timer = be32_to_cpu(dqp->q_core.d_itimer);
warns = INT_GET(dqp->q_core.d_iwarns, ARCH_CONVERT); warns = be16_to_cpu(dqp->q_core.d_iwarns);
warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount); warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount);
hardlimit = INT_GET(dqp->q_core.d_ino_hardlimit, hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
ARCH_CONVERT);
if (!hardlimit) if (!hardlimit)
hardlimit = q->qi_ihardlimit; hardlimit = q->qi_ihardlimit;
softlimit = INT_GET(dqp->q_core.d_ino_softlimit, softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
ARCH_CONVERT);
if (!softlimit) if (!softlimit)
softlimit = q->qi_isoftlimit; softlimit = q->qi_isoftlimit;
if (hardlimit > 0ULL && count >= hardlimit) { if (hardlimit > 0ULL && count >= hardlimit) {
@ -756,9 +738,9 @@ xfs_trans_dqresv(
XFS_TRANS_DQ_RES_INOS, XFS_TRANS_DQ_RES_INOS,
ninos); ninos);
} }
ASSERT(dqp->q_res_bcount >= INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); ASSERT(dqp->q_res_bcount >= be64_to_cpu(dqp->q_core.d_bcount));
ASSERT(dqp->q_res_rtbcount >= INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount));
ASSERT(dqp->q_res_icount >= INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount));
error_return: error_return:
if (! (flags & XFS_QMOPT_DQLOCK)) { if (! (flags & XFS_QMOPT_DQLOCK)) {

View file

@ -1,38 +1,22 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "debug.h" #include "debug.h"
#include "spin.h" #include "spin.h"
#include <asm/page.h> #include <asm/page.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kernel.h> #include <linux/kernel.h>

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_DEBUG_H__ #ifndef __XFS_SUPPORT_DEBUG_H__
#define __XFS_SUPPORT_DEBUG_H__ #define __XFS_SUPPORT_DEBUG_H__
@ -41,9 +27,10 @@
#define CE_ALERT 1 /* alert */ #define CE_ALERT 1 /* alert */
#define CE_PANIC 0 /* panic */ #define CE_PANIC 0 /* panic */
extern void icmn_err(int, char *, va_list); extern void icmn_err(int, char *, va_list)
/* PRINTFLIKE2 */ __attribute__ ((format (printf, 2, 0)));
extern void cmn_err(int, char *, ...); extern void cmn_err(int, char *, ...)
__attribute__ ((format (printf, 2, 3)));
#ifndef STATIC #ifndef STATIC
# define STATIC static # define STATIC static

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include <xfs.h> #include <xfs.h>
static kmem_zone_t *ktrace_hdr_zone; static kmem_zone_t *ktrace_hdr_zone;
@ -65,7 +50,7 @@ ktrace_uninit(void)
* number of entries. * number of entries.
*/ */
ktrace_t * ktrace_t *
ktrace_alloc(int nentries, int sleep) ktrace_alloc(int nentries, unsigned int __nocast sleep)
{ {
ktrace_t *ktp; ktrace_t *ktp;
ktrace_entry_t *ktep; ktrace_entry_t *ktep;

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_KTRACE_H__ #ifndef __XFS_SUPPORT_KTRACE_H__
#define __XFS_SUPPORT_KTRACE_H__ #define __XFS_SUPPORT_KTRACE_H__
@ -66,7 +52,7 @@ typedef struct ktrace_snap {
extern void ktrace_init(int zentries); extern void ktrace_init(int zentries);
extern void ktrace_uninit(void); extern void ktrace_uninit(void);
extern ktrace_t *ktrace_alloc(int, int); extern ktrace_t *ktrace_alloc(int, unsigned int __nocast);
extern void ktrace_free(ktrace_t *); extern void ktrace_free(ktrace_t *);
extern void ktrace_enter( extern void ktrace_enter(

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include <xfs.h> #include <xfs.h>
/* Read from kernel buffer at src to user/kernel buffer defined /* Read from kernel buffer at src to user/kernel buffer defined

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
* *
* Portions Copyright (c) 1982, 1986, 1993, 1994 * Portions Copyright (c) 1982, 1986, 1993, 1994
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.

View file

@ -1,155 +0,0 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <linux/kernel.h>
#include <linux/string.h>
/*
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/
#define swapcode(TYPE, parmi, parmj, n) { \
long i = (n) / sizeof (TYPE); \
register TYPE *pi = (TYPE *) (parmi); \
register TYPE *pj = (TYPE *) (parmj); \
do { \
register TYPE t = *pi; \
*pi++ = *pj; \
*pj++ = t; \
} while (--i > 0); \
}
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
static __inline void
swapfunc(char *a, char *b, int n, int swaptype)
{
if (swaptype <= 1)
swapcode(long, a, b, n)
else
swapcode(char, a, b, n)
}
#define swap(a, b) \
if (swaptype == 0) { \
long t = *(long *)(a); \
*(long *)(a) = *(long *)(b); \
*(long *)(b) = t; \
} else \
swapfunc(a, b, es, swaptype)
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
static __inline char *
med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
{
return cmp(a, b) < 0 ?
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
}
void
qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
{
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
int d, r, swaptype, swap_cnt;
register char *a = aa;
loop: SWAPINIT(a, es);
swap_cnt = 0;
if (n < 7) {
for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
pl -= es)
swap(pl, pl - es);
return;
}
pm = (char *)a + (n / 2) * es;
if (n > 7) {
pl = (char *)a;
pn = (char *)a + (n - 1) * es;
if (n > 40) {
d = (n / 8) * es;
pl = med3(pl, pl + d, pl + 2 * d, cmp);
pm = med3(pm - d, pm, pm + d, cmp);
pn = med3(pn - 2 * d, pn - d, pn, cmp);
}
pm = med3(pl, pm, pn, cmp);
}
swap(a, pm);
pa = pb = (char *)a + es;
pc = pd = (char *)a + (n - 1) * es;
for (;;) {
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
if (r == 0) {
swap_cnt = 1;
swap(pa, pb);
pa += es;
}
pb += es;
}
while (pb <= pc && (r = cmp(pc, a)) >= 0) {
if (r == 0) {
swap_cnt = 1;
swap(pc, pd);
pd -= es;
}
pc -= es;
}
if (pb > pc)
break;
swap(pb, pc);
swap_cnt = 1;
pb += es;
pc -= es;
}
if (swap_cnt == 0) { /* Switch to insertion sort */
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
pl -= es)
swap(pl, pl - es);
return;
}
pn = (char *)a + n * es;
r = min(pa - (char *)a, pb - pa);
vecswap(a, pb - r, r);
r = min((long)(pd - pc), (long)(pn - pd - es));
vecswap(pb, pn - r, r);
if ((r = pb - pa) > es)
qsort(a, r / es, es, cmp);
if ((r = pd - pc) > es) {
/* Iterate rather than recurse to save stack space */
a = pn - r;
n = r / es;
goto loop;
}
/* qsort(pn - r, r / es, es, cmp);*/
}

View file

@ -1,41 +0,0 @@
/*
* Copyright (c) 2000-2002 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 QSORT_H
#define QSORT_H
extern void qsort (void *const pbase,
size_t total_elems,
size_t size,
int (*cmp)(const void *, const void *));
#endif

View file

@ -1,35 +1,20 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include <xfs.h> #include <xfs.h>
static mutex_t uuid_monitor; static mutex_t uuid_monitor;

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_SUPPORT_UUID_H__ #ifndef __XFS_SUPPORT_UUID_H__
#define __XFS_SUPPORT_UUID_H__ #define __XFS_SUPPORT_UUID_H__
@ -36,13 +22,13 @@ typedef struct {
unsigned char __u_bits[16]; unsigned char __u_bits[16];
} uuid_t; } uuid_t;
void uuid_init(void); extern void uuid_init(void);
void uuid_create_nil(uuid_t *uuid); extern void uuid_create_nil(uuid_t *uuid);
int uuid_is_nil(uuid_t *uuid); extern int uuid_is_nil(uuid_t *uuid);
int uuid_equal(uuid_t *uuid1, uuid_t *uuid2); extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]); extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
__uint64_t uuid_hash64(uuid_t *uuid); extern __uint64_t uuid_hash64(uuid_t *uuid);
int uuid_table_insert(uuid_t *uuid); extern int uuid_table_insert(uuid_t *uuid);
void uuid_table_remove(uuid_t *uuid); extern void uuid_table_remove(uuid_t *uuid);
#endif /* __XFS_SUPPORT_UUID_H__ */ #endif /* __XFS_SUPPORT_UUID_H__ */

View file

@ -1,40 +1,28 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_H__ #ifndef __XFS_H__
#define __XFS_H__ #define __XFS_H__
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <linux-2.6/xfs_linux.h> #include <linux-2.6/xfs_linux.h>
#else
#include <xfs_fs.h> #include <linux-2.4/xfs_linux.h>
#include <xfs_macros.h> #endif
#endif /* __XFS_H__ */ #endif /* __XFS_H__ */

View file

@ -1,49 +1,37 @@
/* /*
* Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_types.h"
#include "xfs_bit.h"
#include "xfs_inum.h" #include "xfs_inum.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_mac.h" #include "xfs_mac.h"
#include "xfs_attr.h" #include "xfs_attr.h"
@ -155,7 +143,7 @@ posix_acl_xattr_to_xfs(
} }
/* /*
* Comparison function called from qsort(). * Comparison function called from xfs_sort().
* Primary key is ae_tag, secondary key is ae_id. * Primary key is ae_tag, secondary key is ae_id.
*/ */
STATIC int STATIC int
@ -189,8 +177,8 @@ posix_acl_xfs_to_xattr(
return -ERANGE; return -ERANGE;
/* Need to sort src XFS ACL by <ae_tag,ae_id> */ /* Need to sort src XFS ACL by <ae_tag,ae_id> */
qsort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]), xfs_sort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]),
xfs_acl_entry_compare); xfs_acl_entry_compare);
dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
dest_entry = &dest->a_entries[0]; dest_entry = &dest->a_entries[0];
@ -448,6 +436,7 @@ xfs_acl_access(
int seen_userobj = 0; int seen_userobj = 0;
matched.ae_tag = 0; /* Invalid type */ matched.ae_tag = 0; /* Invalid type */
matched.ae_perm = 0;
md >>= 6; /* Normalize the bits for comparison */ md >>= 6; /* Normalize the bits for comparison */
for (i = 0; i < fap->acl_cnt; i++) { for (i = 0; i < fap->acl_cnt; i++) {

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ACL_H__ #ifndef __XFS_ACL_H__
#define __XFS_ACL_H__ #define __XFS_ACL_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_AG_H__ #ifndef __XFS_AG_H__
#define __XFS_AG_H__ #define __XFS_AG_H__
@ -46,18 +32,9 @@ struct xfs_trans;
#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */
#define XFS_AGF_VERSION 1 #define XFS_AGF_VERSION 1
#define XFS_AGI_VERSION 1 #define XFS_AGI_VERSION 1
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_GOOD_VERSION)
int xfs_agf_good_version(unsigned v); #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
#define XFS_AGF_GOOD_VERSION(v) xfs_agf_good_version(v) #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
#else
#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_GOOD_VERSION)
int xfs_agi_good_version(unsigned v);
#define XFS_AGI_GOOD_VERSION(v) xfs_agi_good_version(v)
#else
#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
#endif
/* /*
* Btree number 0 is bno, 1 is cnt. This value gives the size of the * Btree number 0 is bno, 1 is cnt. This value gives the size of the
@ -71,27 +48,26 @@ int xfs_agi_good_version(unsigned v);
* are > 64k, our value cannot be confused for an EFS superblock's. * are > 64k, our value cannot be confused for an EFS superblock's.
*/ */
typedef struct xfs_agf typedef struct xfs_agf {
{
/* /*
* Common allocation group header information * Common allocation group header information
*/ */
__uint32_t agf_magicnum; /* magic number == XFS_AGF_MAGIC */ __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */
__uint32_t agf_versionnum; /* header version == XFS_AGF_VERSION */ __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */
xfs_agnumber_t agf_seqno; /* sequence # starting from 0 */ __be32 agf_seqno; /* sequence # starting from 0 */
xfs_agblock_t agf_length; /* size in blocks of a.g. */ __be32 agf_length; /* size in blocks of a.g. */
/* /*
* Freespace information * Freespace information
*/ */
xfs_agblock_t agf_roots[XFS_BTNUM_AGF]; /* root blocks */ __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */
__uint32_t agf_spare0; /* spare field */ __be32 agf_spare0; /* spare field */
__uint32_t agf_levels[XFS_BTNUM_AGF]; /* btree levels */ __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */
__uint32_t agf_spare1; /* spare field */ __be32 agf_spare1; /* spare field */
__uint32_t agf_flfirst; /* first freelist block's index */ __be32 agf_flfirst; /* first freelist block's index */
__uint32_t agf_fllast; /* last freelist block's index */ __be32 agf_fllast; /* last freelist block's index */
__uint32_t agf_flcount; /* count of blocks in freelist */ __be32 agf_flcount; /* count of blocks in freelist */
xfs_extlen_t agf_freeblks; /* total free blocks */ __be32 agf_freeblks; /* total free blocks */
xfs_extlen_t agf_longest; /* longest free space */ __be32 agf_longest; /* longest free space */
} xfs_agf_t; } xfs_agf_t;
#define XFS_AGF_MAGICNUM 0x00000001 #define XFS_AGF_MAGICNUM 0x00000001
@ -110,43 +86,39 @@ typedef struct xfs_agf
/* disk block (xfs_daddr_t) in the AG */ /* disk block (xfs_daddr_t) in the AG */
#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_BLOCK) #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
xfs_agblock_t xfs_agf_block(struct xfs_mount *mp); #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
#define XFS_AGF_BLOCK(mp) xfs_agf_block(mp)
#else
#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
#endif
/* /*
* Size of the unlinked inode hash table in the agi. * Size of the unlinked inode hash table in the agi.
*/ */
#define XFS_AGI_UNLINKED_BUCKETS 64 #define XFS_AGI_UNLINKED_BUCKETS 64
typedef struct xfs_agi typedef struct xfs_agi {
{
/* /*
* Common allocation group header information * Common allocation group header information
*/ */
__uint32_t agi_magicnum; /* magic number == XFS_AGI_MAGIC */ __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */
__uint32_t agi_versionnum; /* header version == XFS_AGI_VERSION */ __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */
xfs_agnumber_t agi_seqno; /* sequence # starting from 0 */ __be32 agi_seqno; /* sequence # starting from 0 */
xfs_agblock_t agi_length; /* size in blocks of a.g. */ __be32 agi_length; /* size in blocks of a.g. */
/* /*
* Inode information * Inode information
* Inodes are mapped by interpreting the inode number, so no * Inodes are mapped by interpreting the inode number, so no
* mapping data is needed here. * mapping data is needed here.
*/ */
xfs_agino_t agi_count; /* count of allocated inodes */ __be32 agi_count; /* count of allocated inodes */
xfs_agblock_t agi_root; /* root of inode btree */ __be32 agi_root; /* root of inode btree */
__uint32_t agi_level; /* levels in inode btree */ __be32 agi_level; /* levels in inode btree */
xfs_agino_t agi_freecount; /* number of free inodes */ __be32 agi_freecount; /* number of free inodes */
xfs_agino_t agi_newino; /* new inode just allocated */ __be32 agi_newino; /* new inode just allocated */
xfs_agino_t agi_dirino; /* last directory inode chunk */ __be32 agi_dirino; /* last directory inode chunk */
/* /*
* Hash table of inodes which have been unlinked but are * Hash table of inodes which have been unlinked but are
* still being referenced. * still being referenced.
*/ */
xfs_agino_t agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS];
} xfs_agi_t; } xfs_agi_t;
#define XFS_AGI_MAGICNUM 0x00000001 #define XFS_AGI_MAGICNUM 0x00000001
@ -165,25 +137,17 @@ typedef struct xfs_agi
/* disk block (xfs_daddr_t) in the AG */ /* disk block (xfs_daddr_t) in the AG */
#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_BLOCK) #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
xfs_agblock_t xfs_agi_block(struct xfs_mount *mp); #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
#define XFS_AGI_BLOCK(mp) xfs_agi_block(mp)
#else
#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
#endif
/* /*
* The third a.g. block contains the a.g. freelist, an array * The third a.g. block contains the a.g. freelist, an array
* of block pointers to blocks owned by the allocation btree code. * of block pointers to blocks owned by the allocation btree code.
*/ */
#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGFL_BLOCK) #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
xfs_agblock_t xfs_agfl_block(struct xfs_mount *mp);
#define XFS_AGFL_BLOCK(mp) xfs_agfl_block(mp)
#else
#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
#endif
#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) #define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))
#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
typedef struct xfs_agfl { typedef struct xfs_agfl {
xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */
@ -230,116 +194,38 @@ typedef struct xfs_perag
xfs_perag_busy_t *pagb_list; /* unstable blocks */ xfs_perag_busy_t *pagb_list; /* unstable blocks */
} xfs_perag_t; } xfs_perag_t;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_MAXLEVELS) #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
int xfs_ag_maxlevels(struct xfs_mount *mp);
#define XFS_AG_MAXLEVELS(mp) xfs_ag_maxlevels(mp)
#else
#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST)
int xfs_min_freelist(xfs_agf_t *a, struct xfs_mount *mp);
#define XFS_MIN_FREELIST(a,mp) xfs_min_freelist(a,mp)
#else
#define XFS_MIN_FREELIST(a,mp) \
XFS_MIN_FREELIST_RAW( \
INT_GET((a)->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT), \
INT_GET((a)->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT), mp)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_PAG)
int xfs_min_freelist_pag(xfs_perag_t *pag, struct xfs_mount *mp);
#define XFS_MIN_FREELIST_PAG(pag,mp) xfs_min_freelist_pag(pag,mp)
#else
#define XFS_MIN_FREELIST_PAG(pag,mp) \
XFS_MIN_FREELIST_RAW((uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
(uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_RAW)
int xfs_min_freelist_raw(int bl, int cl, struct xfs_mount *mp);
#define XFS_MIN_FREELIST_RAW(bl,cl,mp) xfs_min_freelist_raw(bl,cl,mp)
#else
#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \
(MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + \ (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp)))
MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) #define XFS_MIN_FREELIST(a,mp) \
#endif (XFS_MIN_FREELIST_RAW( \
be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \
be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp))
#define XFS_MIN_FREELIST_PAG(pag,mp) \
(XFS_MIN_FREELIST_RAW( \
(uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
(uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_FSB) #define XFS_AGB_TO_FSB(mp,agno,agbno) \
xfs_fsblock_t xfs_agb_to_fsb(struct xfs_mount *mp, xfs_agnumber_t agno,
xfs_agblock_t agbno);
#define XFS_AGB_TO_FSB(mp,agno,agbno) xfs_agb_to_fsb(mp,agno,agbno)
#else
#define XFS_AGB_TO_FSB(mp,agno,agbno) \
(((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))
#endif #define XFS_FSB_TO_AGNO(mp,fsbno) \
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGNO)
xfs_agnumber_t xfs_fsb_to_agno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
#define XFS_FSB_TO_AGNO(mp,fsbno) xfs_fsb_to_agno(mp,fsbno)
#else
#define XFS_FSB_TO_AGNO(mp,fsbno) \
((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog))
#endif #define XFS_FSB_TO_AGBNO(mp,fsbno) \
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGBNO)
xfs_agblock_t xfs_fsb_to_agbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
#define XFS_FSB_TO_AGBNO(mp,fsbno) xfs_fsb_to_agbno(mp,fsbno)
#else
#define XFS_FSB_TO_AGBNO(mp,fsbno) \
((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog)))
#endif #define XFS_AGB_TO_DADDR(mp,agno,agbno) \
((xfs_daddr_t)XFS_FSB_TO_BB(mp, \
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_DADDR) (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))
xfs_daddr_t xfs_agb_to_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
xfs_agblock_t agbno);
#define XFS_AGB_TO_DADDR(mp,agno,agbno) xfs_agb_to_daddr(mp,agno,agbno)
#else
#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
((xfs_daddr_t)(XFS_FSB_TO_BB(mp, \
(xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))))
#endif
/*
* XFS_DADDR_TO_AGNO and XFS_DADDR_TO_AGBNO moved to xfs_mount.h
* to avoid header file ordering change
*/
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_DADDR)
xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno,
xfs_daddr_t d);
#define XFS_AG_DADDR(mp,agno,d) xfs_ag_daddr(mp,agno,d)
#else
#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGF)
xfs_agf_t *xfs_buf_to_agf(struct xfs_buf *bp);
#define XFS_BUF_TO_AGF(bp) xfs_buf_to_agf(bp)
#else
#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGI)
xfs_agi_t *xfs_buf_to_agi(struct xfs_buf *bp);
#define XFS_BUF_TO_AGI(bp) xfs_buf_to_agi(bp)
#else
#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGFL)
xfs_agfl_t *xfs_buf_to_agfl(struct xfs_buf *bp);
#define XFS_BUF_TO_AGFL(bp) xfs_buf_to_agfl(bp)
#else
#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
#endif
/* /*
* For checking for bad ranges of xfs_daddr_t's, covering multiple * For checking for bad ranges of xfs_daddr_t's, covering multiple
* allocation groups or a single xfs_daddr_t that's a superblock copy. * allocation groups or a single xfs_daddr_t that's a superblock copy.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_CHECK_DADDR)
void xfs_ag_check_daddr(struct xfs_mount *mp, xfs_daddr_t d, xfs_extlen_t len);
#define XFS_AG_CHECK_DADDR(mp,d,len) xfs_ag_check_daddr(mp,d,len)
#else
#define XFS_AG_CHECK_DADDR(mp,d,len) \ #define XFS_AG_CHECK_DADDR(mp,d,len) \
((len) == 1 ? \ ((len) == 1 ? \
ASSERT((d) == XFS_SB_DADDR || \ ASSERT((d) == XFS_SB_DADDR || \
XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \
ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \
XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1)))
#endif
#endif /* __XFS_AG_H__ */ #endif /* __XFS_AG_H__ */

View file

@ -1,56 +1,44 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/
/*
* Free space allocation for XFS.
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_macros.h" #include "xfs_fs.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h"
#include "xfs_inode.h"
#include "xfs_btree.h" #include "xfs_btree.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_bit.h"
#include "xfs_error.h" #include "xfs_error.h"
@ -243,8 +231,8 @@ xfs_alloc_fix_minleft(
if (args->minleft == 0) if (args->minleft == 0)
return 1; return 1;
agf = XFS_BUF_TO_AGF(args->agbp); agf = XFS_BUF_TO_AGF(args->agbp);
diff = INT_GET(agf->agf_freeblks, ARCH_CONVERT) diff = be32_to_cpu(agf->agf_freeblks)
+ INT_GET(agf->agf_flcount, ARCH_CONVERT) + be32_to_cpu(agf->agf_flcount)
- args->len - args->minleft; - args->len - args->minleft;
if (diff >= 0) if (diff >= 0)
return 1; return 1;
@ -319,7 +307,8 @@ xfs_alloc_fixup_trees(
bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]);
cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]);
XFS_WANT_CORRUPTED_RETURN( XFS_WANT_CORRUPTED_RETURN(
INT_GET(bnoblock->bb_numrecs, ARCH_CONVERT) == INT_GET(cntblock->bb_numrecs, ARCH_CONVERT)); be16_to_cpu(bnoblock->bb_numrecs) ==
be16_to_cpu(cntblock->bb_numrecs));
} }
} }
#endif #endif
@ -505,21 +494,17 @@ xfs_alloc_trace_modagf(
(void *)str, (void *)str,
(void *)mp, (void *)mp,
(void *)(__psint_t)flags, (void *)(__psint_t)flags,
(void *)(__psunsigned_t)INT_GET(agf->agf_seqno, ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno),
(void *)(__psunsigned_t)INT_GET(agf->agf_length, ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length),
(void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_BNO], (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
(void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_CNT], (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
(void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_BNO], (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst),
ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast),
(void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_CNT], (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount),
ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks),
(void *)(__psunsigned_t)INT_GET(agf->agf_flfirst, ARCH_CONVERT), (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest));
(void *)(__psunsigned_t)INT_GET(agf->agf_fllast, ARCH_CONVERT),
(void *)(__psunsigned_t)INT_GET(agf->agf_flcount, ARCH_CONVERT),
(void *)(__psunsigned_t)INT_GET(agf->agf_freeblks, ARCH_CONVERT),
(void *)(__psunsigned_t)INT_GET(agf->agf_longest, ARCH_CONVERT));
} }
STATIC void STATIC void
@ -612,12 +597,12 @@ xfs_alloc_ag_vextent(
if (!(args->wasfromfl)) { if (!(args->wasfromfl)) {
agf = XFS_BUF_TO_AGF(args->agbp); agf = XFS_BUF_TO_AGF(args->agbp);
INT_MOD(agf->agf_freeblks, ARCH_CONVERT, -(args->len)); be32_add(&agf->agf_freeblks, -(args->len));
xfs_trans_agblocks_delta(args->tp, xfs_trans_agblocks_delta(args->tp,
-((long)(args->len))); -((long)(args->len)));
args->pag->pagf_freeblks -= args->len; args->pag->pagf_freeblks -= args->len;
ASSERT(INT_GET(agf->agf_freeblks, ARCH_CONVERT) ASSERT(be32_to_cpu(agf->agf_freeblks) <=
<= INT_GET(agf->agf_length, ARCH_CONVERT)); be32_to_cpu(agf->agf_length));
TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
xfs_alloc_log_agf(args->tp, args->agbp, xfs_alloc_log_agf(args->tp, args->agbp,
XFS_AGF_FREEBLKS); XFS_AGF_FREEBLKS);
@ -723,8 +708,7 @@ xfs_alloc_ag_vextent_exact(
cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_CNT, NULL, 0); args->agno, XFS_BTNUM_CNT, NULL, 0);
ASSERT(args->agbno + args->len <= ASSERT(args->agbno + args->len <=
INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
ARCH_CONVERT));
if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { args->agbno, args->len, XFSA_FIXUP_BNO_OK))) {
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
@ -897,8 +881,7 @@ xfs_alloc_ag_vextent_near(
goto error0; goto error0;
XFS_WANT_CORRUPTED_GOTO(i == 1, error0); XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
ltend = ltbno + ltlen; ltend = ltbno + ltlen;
ASSERT(ltend <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, ASSERT(ltend <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
ARCH_CONVERT));
args->len = blen; args->len = blen;
if (!xfs_alloc_fix_minleft(args)) { if (!xfs_alloc_fix_minleft(args)) {
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
@ -1253,8 +1236,7 @@ xfs_alloc_ag_vextent_near(
ltlen, &ltnew); ltlen, &ltnew);
ASSERT(ltnew >= ltbno); ASSERT(ltnew >= ltbno);
ASSERT(ltnew + rlen <= ltend); ASSERT(ltnew + rlen <= ltend);
ASSERT(ltnew + rlen <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
ARCH_CONVERT));
args->agbno = ltnew; args->agbno = ltnew;
if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen,
ltnew, rlen, XFSA_FIXUP_BNO_OK))) ltnew, rlen, XFSA_FIXUP_BNO_OK)))
@ -1417,8 +1399,7 @@ xfs_alloc_ag_vextent_size(
args->agbno = rbno; args->agbno = rbno;
XFS_WANT_CORRUPTED_GOTO( XFS_WANT_CORRUPTED_GOTO(
args->agbno + args->len <= args->agbno + args->len <=
INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
ARCH_CONVERT),
error0); error0);
TRACE_ALLOC("normal", args); TRACE_ALLOC("normal", args);
return 0; return 0;
@ -1466,8 +1447,8 @@ xfs_alloc_ag_vextent_small(
* freelist. * freelist.
*/ */
else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && else if (args->minlen == 1 && args->alignment == 1 && !args->isfl &&
(INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount, (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
ARCH_CONVERT) > args->minleft)) { > args->minleft)) {
if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno)))
goto error0; goto error0;
if (fbno != NULLAGBLOCK) { if (fbno != NULLAGBLOCK) {
@ -1482,8 +1463,7 @@ xfs_alloc_ag_vextent_small(
args->agbno = fbno; args->agbno = fbno;
XFS_WANT_CORRUPTED_GOTO( XFS_WANT_CORRUPTED_GOTO(
args->agbno + args->len <= args->agbno + args->len <=
INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
ARCH_CONVERT),
error0); error0);
args->wasfromfl = 1; args->wasfromfl = 1;
TRACE_ALLOC("freelist", args); TRACE_ALLOC("freelist", args);
@ -1757,12 +1737,12 @@ xfs_free_ag_extent(
agf = XFS_BUF_TO_AGF(agbp); agf = XFS_BUF_TO_AGF(agbp);
pag = &mp->m_perag[agno]; pag = &mp->m_perag[agno];
INT_MOD(agf->agf_freeblks, ARCH_CONVERT, len); be32_add(&agf->agf_freeblks, len);
xfs_trans_agblocks_delta(tp, len); xfs_trans_agblocks_delta(tp, len);
pag->pagf_freeblks += len; pag->pagf_freeblks += len;
XFS_WANT_CORRUPTED_GOTO( XFS_WANT_CORRUPTED_GOTO(
INT_GET(agf->agf_freeblks, ARCH_CONVERT) be32_to_cpu(agf->agf_freeblks) <=
<= INT_GET(agf->agf_length, ARCH_CONVERT), be32_to_cpu(agf->agf_length),
error0); error0);
TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
@ -1909,18 +1889,18 @@ xfs_alloc_fix_freelist(
*/ */
agf = XFS_BUF_TO_AGF(agbp); agf = XFS_BUF_TO_AGF(agbp);
need = XFS_MIN_FREELIST(agf, mp); need = XFS_MIN_FREELIST(agf, mp);
delta = need > INT_GET(agf->agf_flcount, ARCH_CONVERT) ? delta = need > be32_to_cpu(agf->agf_flcount) ?
(need - INT_GET(agf->agf_flcount, ARCH_CONVERT)) : 0; (need - be32_to_cpu(agf->agf_flcount)) : 0;
/* /*
* If there isn't enough total or single-extent, reject it. * If there isn't enough total or single-extent, reject it.
*/ */
longest = INT_GET(agf->agf_longest, ARCH_CONVERT); longest = be32_to_cpu(agf->agf_longest);
longest = (longest > delta) ? (longest - delta) : longest = (longest > delta) ? (longest - delta) :
(INT_GET(agf->agf_flcount, ARCH_CONVERT) > 0 || longest > 0); (be32_to_cpu(agf->agf_flcount) > 0 || longest > 0);
if (args->minlen + args->alignment + args->minalignslop - 1 > longest || if (args->minlen + args->alignment + args->minalignslop - 1 > longest ||
(args->minleft && (args->minleft &&
(int)(INT_GET(agf->agf_freeblks, ARCH_CONVERT) + (int)(be32_to_cpu(agf->agf_freeblks) +
INT_GET(agf->agf_flcount, ARCH_CONVERT) - need - args->total) < be32_to_cpu(agf->agf_flcount) - need - args->total) <
(int)args->minleft)) { (int)args->minleft)) {
xfs_trans_brelse(tp, agbp); xfs_trans_brelse(tp, agbp);
args->agbp = NULL; args->agbp = NULL;
@ -1929,7 +1909,7 @@ xfs_alloc_fix_freelist(
/* /*
* Make the freelist shorter if it's too long. * Make the freelist shorter if it's too long.
*/ */
while (INT_GET(agf->agf_flcount, ARCH_CONVERT) > need) { while (be32_to_cpu(agf->agf_flcount) > need) {
xfs_buf_t *bp; xfs_buf_t *bp;
if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) if ((error = xfs_alloc_get_freelist(tp, agbp, &bno)))
@ -1956,9 +1936,9 @@ xfs_alloc_fix_freelist(
/* /*
* Make the freelist longer if it's too short. * Make the freelist longer if it's too short.
*/ */
while (INT_GET(agf->agf_flcount, ARCH_CONVERT) < need) { while (be32_to_cpu(agf->agf_flcount) < need) {
targs.agbno = 0; targs.agbno = 0;
targs.maxlen = need - INT_GET(agf->agf_flcount, ARCH_CONVERT); targs.maxlen = need - be32_to_cpu(agf->agf_flcount);
/* /*
* Allocate as many blocks as possible at once. * Allocate as many blocks as possible at once.
*/ */
@ -2018,19 +1998,19 @@ xfs_alloc_get_freelist(
*/ */
mp = tp->t_mountp; mp = tp->t_mountp;
if ((error = xfs_alloc_read_agfl(mp, tp, if ((error = xfs_alloc_read_agfl(mp, tp,
INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) be32_to_cpu(agf->agf_seqno), &agflbp)))
return error; return error;
agfl = XFS_BUF_TO_AGFL(agflbp); agfl = XFS_BUF_TO_AGFL(agflbp);
/* /*
* Get the block number and update the data structures. * Get the block number and update the data structures.
*/ */
bno = INT_GET(agfl->agfl_bno[INT_GET(agf->agf_flfirst, ARCH_CONVERT)], ARCH_CONVERT); bno = INT_GET(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)], ARCH_CONVERT);
INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1); be32_add(&agf->agf_flfirst, 1);
xfs_trans_brelse(tp, agflbp); xfs_trans_brelse(tp, agflbp);
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp))
agf->agf_flfirst = 0; agf->agf_flfirst = 0;
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1); be32_add(&agf->agf_flcount, -1);
xfs_trans_agflist_delta(tp, -1); xfs_trans_agflist_delta(tp, -1);
pag->pagf_flcount--; pag->pagf_flcount--;
TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT);
@ -2045,7 +2025,7 @@ xfs_alloc_get_freelist(
* the freeing transaction must be pushed to disk NOW by forcing * the freeing transaction must be pushed to disk NOW by forcing
* to disk all iclogs up that transaction's LSN. * to disk all iclogs up that transaction's LSN.
*/ */
xfs_alloc_search_busy(tp, INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); xfs_alloc_search_busy(tp, be32_to_cpu(agf->agf_seqno), bno, 1);
return 0; return 0;
} }
@ -2123,18 +2103,18 @@ xfs_alloc_put_freelist(
mp = tp->t_mountp; mp = tp->t_mountp;
if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp,
INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) be32_to_cpu(agf->agf_seqno), &agflbp)))
return error; return error;
agfl = XFS_BUF_TO_AGFL(agflbp); agfl = XFS_BUF_TO_AGFL(agflbp);
INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1); be32_add(&agf->agf_fllast, 1);
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp))
agf->agf_fllast = 0; agf->agf_fllast = 0;
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1); be32_add(&agf->agf_flcount, 1);
xfs_trans_agflist_delta(tp, 1); xfs_trans_agflist_delta(tp, 1);
pag->pagf_flcount++; pag->pagf_flcount++;
ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)); ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)]; blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)];
INT_SET(*blockp, ARCH_CONVERT, bno); INT_SET(*blockp, ARCH_CONVERT, bno);
TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
@ -2181,14 +2161,12 @@ xfs_alloc_read_agf(
*/ */
agf = XFS_BUF_TO_AGF(bp); agf = XFS_BUF_TO_AGF(bp);
agf_ok = agf_ok =
INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC && be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC &&
XFS_AGF_GOOD_VERSION( XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
INT_GET(agf->agf_versionnum, ARCH_CONVERT)) && be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
INT_GET(agf->agf_freeblks, ARCH_CONVERT) <= be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) &&
INT_GET(agf->agf_length, ARCH_CONVERT) && be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) &&
INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp);
INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) &&
INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp);
if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF,
XFS_RANDOM_ALLOC_READ_AGF))) { XFS_RANDOM_ALLOC_READ_AGF))) {
XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", XFS_CORRUPTION_ERROR("xfs_alloc_read_agf",
@ -2198,13 +2176,13 @@ xfs_alloc_read_agf(
} }
pag = &mp->m_perag[agno]; pag = &mp->m_perag[agno];
if (!pag->pagf_init) { if (!pag->pagf_init) {
pag->pagf_freeblks = INT_GET(agf->agf_freeblks, ARCH_CONVERT); pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks);
pag->pagf_flcount = INT_GET(agf->agf_flcount, ARCH_CONVERT); pag->pagf_flcount = be32_to_cpu(agf->agf_flcount);
pag->pagf_longest = INT_GET(agf->agf_longest, ARCH_CONVERT); pag->pagf_longest = be32_to_cpu(agf->agf_longest);
pag->pagf_levels[XFS_BTNUM_BNOi] = pag->pagf_levels[XFS_BTNUM_BNOi] =
INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT); be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]);
pag->pagf_levels[XFS_BTNUM_CNTi] = pag->pagf_levels[XFS_BTNUM_CNTi] =
INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT); be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]);
spinlock_init(&pag->pagb_lock, "xfspagb"); spinlock_init(&pag->pagb_lock, "xfspagb");
pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS *
sizeof(xfs_perag_busy_t), KM_SLEEP); sizeof(xfs_perag_busy_t), KM_SLEEP);
@ -2212,13 +2190,13 @@ xfs_alloc_read_agf(
} }
#ifdef DEBUG #ifdef DEBUG
else if (!XFS_FORCED_SHUTDOWN(mp)) { else if (!XFS_FORCED_SHUTDOWN(mp)) {
ASSERT(pag->pagf_freeblks == INT_GET(agf->agf_freeblks, ARCH_CONVERT)); ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks));
ASSERT(pag->pagf_flcount == INT_GET(agf->agf_flcount, ARCH_CONVERT)); ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount));
ASSERT(pag->pagf_longest == INT_GET(agf->agf_longest, ARCH_CONVERT)); ASSERT(pag->pagf_longest == be32_to_cpu(agf->agf_longest));
ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] ==
INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT)); be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]));
ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] ==
INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT)); be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]));
} }
#endif #endif
XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF); XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF);
@ -2467,7 +2445,7 @@ xfs_free_extent(
#ifdef DEBUG #ifdef DEBUG
ASSERT(args.agbp != NULL); ASSERT(args.agbp != NULL);
agf = XFS_BUF_TO_AGF(args.agbp); agf = XFS_BUF_TO_AGF(args.agbp);
ASSERT(args.agbno + len <= INT_GET(agf->agf_length, ARCH_CONVERT)); ASSERT(args.agbno + len <= be32_to_cpu(agf->agf_length));
#endif #endif
error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno, error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno,
len, 0); len, 0);

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ALLOC_H__ #ifndef __XFS_ALLOC_H__
#define __XFS_ALLOC_H__ #define __XFS_ALLOC_H__

File diff suppressed because it is too large Load diff

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ALLOC_BTREE_H__ #ifndef __XFS_ALLOC_BTREE_H__
#define __XFS_ALLOC_BTREE_H__ #define __XFS_ALLOC_BTREE_H__
@ -52,48 +38,29 @@ struct xfs_mount;
/* /*
* Data record/key structure * Data record/key structure
*/ */
typedef struct xfs_alloc_rec typedef struct xfs_alloc_rec {
{ __be32 ar_startblock; /* starting block number */
xfs_agblock_t ar_startblock; /* starting block number */ __be32 ar_blockcount; /* count of free blocks */
xfs_extlen_t ar_blockcount; /* count of free blocks */
} xfs_alloc_rec_t, xfs_alloc_key_t; } xfs_alloc_rec_t, xfs_alloc_key_t;
typedef xfs_agblock_t xfs_alloc_ptr_t; /* btree pointer type */ typedef struct xfs_alloc_rec_incore {
/* btree block header type */ xfs_agblock_t ar_startblock; /* starting block number */
xfs_extlen_t ar_blockcount; /* count of free blocks */
} xfs_alloc_rec_incore_t;
/* btree pointer type */
typedef __be32 xfs_alloc_ptr_t;
/* btree block header type */
typedef struct xfs_btree_sblock xfs_alloc_block_t; typedef struct xfs_btree_sblock xfs_alloc_block_t;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) #define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp))
xfs_alloc_block_t *xfs_buf_to_alloc_block(struct xfs_buf *bp);
#define XFS_BUF_TO_ALLOC_BLOCK(bp) xfs_buf_to_alloc_block(bp)
#else
#define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)(XFS_BUF_PTR(bp)))
#endif
/* /*
* Real block structures have a size equal to the disk block size. * Real block structures have a size equal to the disk block size.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_SIZE)
int xfs_alloc_block_size(int lev, struct xfs_btree_cur *cur);
#define XFS_ALLOC_BLOCK_SIZE(lev,cur) xfs_alloc_block_size(lev,cur)
#else
#define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) #define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
#endif #define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0])
#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0])
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MAXRECS)
int xfs_alloc_block_maxrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) xfs_alloc_block_maxrecs(lev,cur)
#else
#define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) \
((cur)->bc_mp->m_alloc_mxr[lev != 0])
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MINRECS)
int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) xfs_alloc_block_minrecs(lev,cur)
#else
#define XFS_ALLOC_BLOCK_MINRECS(lev,cur) \
((cur)->bc_mp->m_alloc_mnr[lev != 0])
#endif
/* /*
* Minimum and maximum blocksize and sectorsize. * Minimum and maximum blocksize and sectorsize.
@ -113,145 +80,80 @@ int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur);
* Block numbers in the AG: * Block numbers in the AG:
* SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BNO_BLOCK)
xfs_agblock_t xfs_bno_block(struct xfs_mount *mp);
#define XFS_BNO_BLOCK(mp) xfs_bno_block(mp)
#else
#define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) #define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CNT_BLOCK)
xfs_agblock_t xfs_cnt_block(struct xfs_mount *mp);
#define XFS_CNT_BLOCK(mp) xfs_cnt_block(mp)
#else
#define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1))
#endif
/* /*
* Record, key, and pointer address macros for btree blocks. * Record, key, and pointer address macros for btree blocks.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_REC_ADDR)
xfs_alloc_rec_t *xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i,
struct xfs_btree_cur *cur);
#define XFS_ALLOC_REC_ADDR(bb,i,cur) xfs_alloc_rec_addr(bb,i,cur)
#else
#define XFS_ALLOC_REC_ADDR(bb,i,cur) \ #define XFS_ALLOC_REC_ADDR(bb,i,cur) \
XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, bb, i, \ XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \
XFS_ALLOC_BLOCK_MAXRECS(0, cur)) bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_KEY_ADDR)
xfs_alloc_key_t *xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i,
struct xfs_btree_cur *cur);
#define XFS_ALLOC_KEY_ADDR(bb,i,cur) xfs_alloc_key_addr(bb,i,cur)
#else
#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ #define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
XFS_ALLOC_BLOCK_MAXRECS(1, cur)) bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_PTR_ADDR)
xfs_alloc_ptr_t *xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i,
struct xfs_btree_cur *cur);
#define XFS_ALLOC_PTR_ADDR(bb,i,cur) xfs_alloc_ptr_addr(bb,i,cur)
#else
#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ #define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \
XFS_ALLOC_BLOCK_MAXRECS(1, cur)) bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
#endif
/*
* Prototypes for externally visible routines.
*/
/* /*
* Decrement cursor by one record at the level. * Decrement cursor by one record at the level.
* For nonzero levels the leaf-ward information is untouched. * For nonzero levels the leaf-ward information is untouched.
*/ */
int /* error */ extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat);
xfs_alloc_decrement(
struct xfs_btree_cur *cur, /* btree cursor */
int level, /* level in btree, 0 is leaf */
int *stat); /* success/failure */
/* /*
* Delete the record pointed to by cur. * Delete the record pointed to by cur.
* The cursor refers to the place where the record was (could be inserted) * The cursor refers to the place where the record was (could be inserted)
* when the operation returns. * when the operation returns.
*/ */
int /* error */ extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat);
xfs_alloc_delete(
struct xfs_btree_cur *cur, /* btree cursor */
int *stat); /* success/failure */
/* /*
* Get the data from the pointed-to record. * Get the data from the pointed-to record.
*/ */
int /* error */ extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno,
xfs_alloc_get_rec( xfs_extlen_t *len, int *stat);
struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t *bno, /* output: starting block of extent */
xfs_extlen_t *len, /* output: length of extent */
int *stat); /* output: success/failure */
/* /*
* Increment cursor by one record at the level. * Increment cursor by one record at the level.
* For nonzero levels the leaf-ward information is untouched. * For nonzero levels the leaf-ward information is untouched.
*/ */
int /* error */ extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat);
xfs_alloc_increment(
struct xfs_btree_cur *cur, /* btree cursor */
int level, /* level in btree, 0 is leaf */
int *stat); /* success/failure */
/* /*
* Insert the current record at the point referenced by cur. * Insert the current record at the point referenced by cur.
* The cursor may be inconsistent on return if splits have been done. * The cursor may be inconsistent on return if splits have been done.
*/ */
int /* error */ extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat);
xfs_alloc_insert(
struct xfs_btree_cur *cur, /* btree cursor */
int *stat); /* success/failure */
/* /*
* Lookup the record equal to [bno, len] in the btree given by cur. * Lookup the record equal to [bno, len] in the btree given by cur.
*/ */
int /* error */ extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_alloc_lookup_eq( xfs_extlen_t len, int *stat);
struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t bno, /* starting block of extent */
xfs_extlen_t len, /* length of extent */
int *stat); /* success/failure */
/* /*
* Lookup the first record greater than or equal to [bno, len] * Lookup the first record greater than or equal to [bno, len]
* in the btree given by cur. * in the btree given by cur.
*/ */
int /* error */ extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_alloc_lookup_ge( xfs_extlen_t len, int *stat);
struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t bno, /* starting block of extent */
xfs_extlen_t len, /* length of extent */
int *stat); /* success/failure */
/* /*
* Lookup the first record less than or equal to [bno, len] * Lookup the first record less than or equal to [bno, len]
* in the btree given by cur. * in the btree given by cur.
*/ */
int /* error */ extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_alloc_lookup_le( xfs_extlen_t len, int *stat);
struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t bno, /* starting block of extent */
xfs_extlen_t len, /* length of extent */
int *stat); /* success/failure */
/* /*
* Update the record referred to by cur, to the value given by [bno, len]. * Update the record referred to by cur, to the value given by [bno, len].
* This either works (return 0) or gets an EFSCORRUPTED error. * This either works (return 0) or gets an EFSCORRUPTED error.
*/ */
int /* error */ extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_alloc_update( xfs_extlen_t len);
struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t bno, /* starting block of extent */
xfs_extlen_t len); /* length of extent */
#endif /* __XFS_ALLOC_BTREE_H__ */ #endif /* __XFS_ALLOC_BTREE_H__ */

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ARCH_H__ #ifndef __XFS_ARCH_H__
#define __XFS_ARCH_H__ #define __XFS_ARCH_H__
@ -168,6 +154,21 @@
} \ } \
} }
static inline void be16_add(__be16 *a, __s16 b)
{
*a = cpu_to_be16(be16_to_cpu(*a) + b);
}
static inline void be32_add(__be32 *a, __s32 b)
{
*a = cpu_to_be32(be32_to_cpu(*a) + b);
}
static inline void be64_add(__be64 *a, __s64 b)
{
*a = cpu_to_be64(be64_to_cpu(*a) + b);
}
/* /*
* In directories inode numbers are stored as unaligned arrays of unsigned * In directories inode numbers are stored as unaligned arrays of unsigned
* 8bit integers on disk. * 8bit integers on disk.

View file

@ -1,41 +1,26 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,27 +28,26 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h" #include "xfs_da_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_inode_item.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_attr_leaf.h" #include "xfs_attr_leaf.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_bit.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_rw.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_rw.h"
/* /*
* xfs_attr.c * xfs_attr.c
@ -122,7 +106,7 @@ ktrace_t *xfs_attr_trace_buf;
*========================================================================*/ *========================================================================*/
int int
xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen, xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
char *value, int *valuelenp, int flags, struct cred *cred) char *value, int *valuelenp, int flags, struct cred *cred)
{ {
xfs_da_args_t args; xfs_da_args_t args;
@ -177,7 +161,7 @@ xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen,
} }
int int
xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp, xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp,
int flags, struct cred *cred) int flags, struct cred *cred)
{ {
xfs_inode_t *ip = XFS_BHVTOI(bdp); xfs_inode_t *ip = XFS_BHVTOI(bdp);
@ -200,40 +184,18 @@ xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp,
return(error); return(error);
} }
/*ARGSUSED*/ STATIC int
int /* error */ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, char *value, int valuelen, int flags)
struct cred *cred)
{ {
xfs_da_args_t args; xfs_da_args_t args;
xfs_inode_t *dp;
xfs_fsblock_t firstblock; xfs_fsblock_t firstblock;
xfs_bmap_free_t flist; xfs_bmap_free_t flist;
int error, err2, committed; int error, err2, committed;
int local, size; int local, size;
uint nblks; uint nblks;
xfs_mount_t *mp; xfs_mount_t *mp = dp->i_mount;
int rsvd = (flags & ATTR_ROOT) != 0; int rsvd = (flags & ATTR_ROOT) != 0;
int namelen;
namelen = strlen(name);
if (namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */
XFS_STATS_INC(xs_attr_set);
dp = XFS_BHVTOI(bdp);
mp = dp->i_mount;
if (XFS_FORCED_SHUTDOWN(mp))
return (EIO);
xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!(flags & ATTR_SECURE) &&
(error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error));
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);
/* /*
* Attach the dquots to the inode. * Attach the dquots to the inode.
@ -241,13 +203,19 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
if ((error = XFS_QM_DQATTACH(mp, dp, 0))) if ((error = XFS_QM_DQATTACH(mp, dp, 0)))
return (error); return (error);
/*
* Determine space new attribute will use, and if it would be
* "local" or "remote" (note: local != inline).
*/
size = xfs_attr_leaf_newentsize(namelen, valuelen,
mp->m_sb.sb_blocksize, &local);
/* /*
* If the inode doesn't have an attribute fork, add one. * If the inode doesn't have an attribute fork, add one.
* (inode must not be locked when we call this routine) * (inode must not be locked when we call this routine)
*/ */
if (XFS_IFORK_Q(dp) == 0) { if (XFS_IFORK_Q(dp) == 0) {
error = xfs_bmap_add_attrfork(dp, rsvd); if ((error = xfs_bmap_add_attrfork(dp, size, rsvd)))
if (error)
return(error); return(error);
} }
@ -265,13 +233,9 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
args.firstblock = &firstblock; args.firstblock = &firstblock;
args.flist = &flist; args.flist = &flist;
args.whichfork = XFS_ATTR_FORK; args.whichfork = XFS_ATTR_FORK;
args.addname = 1;
args.oknoent = 1; args.oknoent = 1;
/* Determine space new attribute will use, and if it will be inline
* or out of line.
*/
size = xfs_attr_leaf_newentsize(&args, mp->m_sb.sb_blocksize, &local);
nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
if (local) { if (local) {
if (size > (mp->m_sb.sb_blocksize >> 1)) { if (size > (mp->m_sb.sb_blocksize >> 1)) {
@ -343,7 +307,7 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
* Build initial attribute list (if required). * Build initial attribute list (if required).
*/ */
if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS)
(void)xfs_attr_shortform_create(&args); xfs_attr_shortform_create(&args);
/* /*
* Try to add the attr to the attribute list in * Try to add the attr to the attribute list in
@ -456,32 +420,21 @@ out:
return(error); return(error);
} }
/* int
* Generic handler routine to remove a name from an attribute list. xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int flags,
* Transitions attribute list from Btree to shortform as necessary. struct cred *cred)
*/
/*ARGSUSED*/
int /* error */
xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
{ {
xfs_da_args_t args; xfs_inode_t *dp;
xfs_inode_t *dp; int namelen, error;
xfs_fsblock_t firstblock;
xfs_bmap_free_t flist;
int error;
xfs_mount_t *mp;
int namelen;
ASSERT(MAXNAMELEN-1<=0xff); /* length is stored in uint8 */
namelen = strlen(name); namelen = strlen(name);
if (namelen>=MAXNAMELEN) if (namelen >= MAXNAMELEN)
return EFAULT; /* match irix behaviour */ return EFAULT; /* match IRIX behaviour */
XFS_STATS_INC(xs_attr_remove); XFS_STATS_INC(xs_attr_set);
dp = XFS_BHVTOI(bdp); dp = XFS_BHVTOI(bdp);
mp = dp->i_mount; if (XFS_FORCED_SHUTDOWN(dp->i_mount))
if (XFS_FORCED_SHUTDOWN(mp))
return (EIO); return (EIO);
xfs_ilock(dp, XFS_ILOCK_SHARED); xfs_ilock(dp, XFS_ILOCK_SHARED);
@ -489,14 +442,25 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
(error = xfs_iaccess(dp, S_IWUSR, cred))) { (error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error)); return(XFS_ERROR(error));
} else if (XFS_IFORK_Q(dp) == 0 ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(ENOATTR));
} }
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
return xfs_attr_set_int(dp, name, namelen, value, valuelen, flags);
}
/*
* Generic handler routine to remove a name from an attribute list.
* Transitions attribute list from Btree to shortform as necessary.
*/
STATIC int
xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
{
xfs_da_args_t args;
xfs_fsblock_t firstblock;
xfs_bmap_free_t flist;
int error;
xfs_mount_t *mp = dp->i_mount;
/* /*
* Fill in the arg structure for this request. * Fill in the arg structure for this request.
*/ */
@ -544,7 +508,6 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
XFS_ATTRRM_LOG_COUNT))) { XFS_ATTRRM_LOG_COUNT))) {
xfs_trans_cancel(args.trans, 0); xfs_trans_cancel(args.trans, 0);
return(error); return(error);
} }
xfs_ilock(dp, XFS_ILOCK_EXCL); xfs_ilock(dp, XFS_ILOCK_EXCL);
@ -612,6 +575,38 @@ out:
return(error); return(error);
} }
int
xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
{
xfs_inode_t *dp;
int namelen, error;
namelen = strlen(name);
if (namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */
XFS_STATS_INC(xs_attr_remove);
dp = XFS_BHVTOI(bdp);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);
xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!(flags & ATTR_SECURE) &&
(error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error));
} else if (XFS_IFORK_Q(dp) == 0 ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(ENOATTR));
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return xfs_attr_remove_int(dp, name, namelen, flags);
}
/* /*
* Generate a list of extended attribute names and optionally * Generate a list of extended attribute names and optionally
* also value lengths. Positive return value follows the XFS * also value lengths. Positive return value follows the XFS
@ -811,7 +806,7 @@ out:
STATIC int STATIC int
xfs_attr_shortform_addname(xfs_da_args_t *args) xfs_attr_shortform_addname(xfs_da_args_t *args)
{ {
int newsize, retval; int newsize, forkoff, retval;
retval = xfs_attr_shortform_lookup(args); retval = xfs_attr_shortform_lookup(args);
if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
@ -823,16 +818,18 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
ASSERT(retval == 0); ASSERT(retval == 0);
} }
if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
return(XFS_ERROR(ENOSPC));
newsize = XFS_ATTR_SF_TOTSIZE(args->dp); newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);
if ((newsize <= XFS_IFORK_ASIZE(args->dp)) &&
(args->namelen < XFS_ATTR_SF_ENTSIZE_MAX) && forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
(args->valuelen < XFS_ATTR_SF_ENTSIZE_MAX)) { if (!forkoff)
retval = xfs_attr_shortform_add(args);
ASSERT(retval == 0);
} else {
return(XFS_ERROR(ENOSPC)); return(XFS_ERROR(ENOSPC));
}
xfs_attr_shortform_add(args, forkoff);
return(0); return(0);
} }
@ -852,7 +849,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
{ {
xfs_inode_t *dp; xfs_inode_t *dp;
xfs_dabuf_t *bp; xfs_dabuf_t *bp;
int retval, error, committed; int retval, error, committed, forkoff;
/* /*
* Read the (only) block in the attribute list in. * Read the (only) block in the attribute list in.
@ -995,9 +992,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
/* /*
* If the result is small enough, shrink it all into the inode. * If the result is small enough, shrink it all into the inode.
*/ */
if (xfs_attr_shortform_allfit(bp, dp)) { if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
XFS_BMAP_INIT(args->flist, args->firstblock); XFS_BMAP_INIT(args->flist, args->firstblock);
error = xfs_attr_leaf_to_shortform(bp, args); error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */
if (!error) { if (!error) {
error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans,
@ -1049,8 +1046,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
{ {
xfs_inode_t *dp; xfs_inode_t *dp;
xfs_dabuf_t *bp; xfs_dabuf_t *bp;
int committed; int error, committed, forkoff;
int error;
/* /*
* Remove the attribute. * Remove the attribute.
@ -1075,9 +1071,9 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
/* /*
* If the result is small enough, shrink it all into the inode. * If the result is small enough, shrink it all into the inode.
*/ */
if (xfs_attr_shortform_allfit(bp, dp)) { if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
XFS_BMAP_INIT(args->flist, args->firstblock); XFS_BMAP_INIT(args->flist, args->firstblock);
error = xfs_attr_leaf_to_shortform(bp, args); error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */
if (!error) { if (!error) {
error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist,
@ -1448,7 +1444,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
xfs_da_state_blk_t *blk; xfs_da_state_blk_t *blk;
xfs_inode_t *dp; xfs_inode_t *dp;
xfs_dabuf_t *bp; xfs_dabuf_t *bp;
int retval, error, committed; int retval, error, committed, forkoff;
/* /*
* Tie a string around our finger to remind us where we are. * Tie a string around our finger to remind us where we are.
@ -1569,9 +1565,9 @@ xfs_attr_node_removename(xfs_da_args_t *args)
bp->data)->hdr.info.magic, ARCH_CONVERT) bp->data)->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC); == XFS_ATTR_LEAF_MAGIC);
if (xfs_attr_shortform_allfit(bp, dp)) { if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
XFS_BMAP_INIT(args->flist, args->firstblock); XFS_BMAP_INIT(args->flist, args->firstblock);
error = xfs_attr_leaf_to_shortform(bp, args); error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */
if (!error) { if (!error) {
error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans,

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ATTR_H__ #ifndef __XFS_ATTR_H__
#define __XFS_ATTR_H__ #define __XFS_ATTR_H__
@ -172,15 +158,15 @@ struct xfs_da_args;
/* /*
* Overall external interface routines. * Overall external interface routines.
*/ */
int xfs_attr_get(bhv_desc_t *, char *, char *, int *, int, struct cred *); int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *);
int xfs_attr_set(bhv_desc_t *, char *, char *, int, int, struct cred *); int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *);
int xfs_attr_remove(bhv_desc_t *, char *, int, struct cred *); int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *);
int xfs_attr_list(bhv_desc_t *, char *, int, int, int xfs_attr_list(bhv_desc_t *, char *, int, int,
struct attrlist_cursor_kern *, struct cred *); struct attrlist_cursor_kern *, struct cred *);
int xfs_attr_inactive(struct xfs_inode *dp); int xfs_attr_inactive(struct xfs_inode *dp);
int xfs_attr_shortform_getvalue(struct xfs_da_args *); int xfs_attr_shortform_getvalue(struct xfs_da_args *);
int xfs_attr_fetch(struct xfs_inode *, char *, int, int xfs_attr_fetch(struct xfs_inode *, const char *, int,
char *, int *, int, struct cred *); char *, int *, int, struct cred *);
#endif /* __XFS_ATTR_H__ */ #endif /* __XFS_ATTR_H__ */

View file

@ -1,46 +1,26 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* xfs_attr_leaf.c
*
* GROT: figure out how to recover gracefully when bmap returns ENOSPC.
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -48,23 +28,22 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h" #include "xfs_da_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_btree.h" #include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_attr_leaf.h" #include "xfs_attr_leaf.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_bit.h"
/* /*
* xfs_attr_leaf.c * xfs_attr_leaf.c
@ -118,13 +97,82 @@ STATIC int xfs_attr_put_listent(xfs_attr_list_context_t *context,
/*======================================================================== /*========================================================================
* External routines when dirsize < XFS_LITINO(mp). * External routines when attribute fork size < XFS_LITINO(mp).
*========================================================================*/ *========================================================================*/
/*
* Query whether the requested number of additional bytes of extended
* attribute space will be able to fit inline.
* Returns zero if not, else the di_forkoff fork offset to be used in the
* literal area for attribute data once the new bytes have been added.
*
* di_forkoff must be 8 byte aligned, hence is stored as a >>3 value;
* special case for dev/uuid inodes, they have fixed size data forks.
*/
int
xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
{
int offset;
int minforkoff; /* lower limit on valid forkoff locations */
int maxforkoff; /* upper limit on valid forkoff locations */
xfs_mount_t *mp = dp->i_mount;
offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */
switch (dp->i_d.di_format) {
case XFS_DINODE_FMT_DEV:
minforkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
return (offset >= minforkoff) ? minforkoff : 0;
case XFS_DINODE_FMT_UUID:
minforkoff = roundup(sizeof(uuid_t), 8) >> 3;
return (offset >= minforkoff) ? minforkoff : 0;
}
if (unlikely(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) {
if (bytes <= XFS_IFORK_ASIZE(dp))
return mp->m_attroffset >> 3;
return 0;
}
/* data fork btree root can have at least this many key/ptr pairs */
minforkoff = MAX(dp->i_df.if_bytes, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
minforkoff = roundup(minforkoff, 8) >> 3;
/* attr fork btree root can have at least this many key/ptr pairs */
maxforkoff = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
maxforkoff = maxforkoff >> 3; /* rounded down */
if (offset >= minforkoff && offset < maxforkoff)
return offset;
if (offset >= maxforkoff)
return maxforkoff;
return 0;
}
/*
* Switch on the ATTR2 superblock bit (implies also FEATURES2)
*/
STATIC void
xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
{
unsigned long s;
if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR) &&
!(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) {
s = XFS_SB_LOCK(mp);
if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
XFS_SB_VERSION_ADDATTR2(&mp->m_sb);
XFS_SB_UNLOCK(mp, s);
xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
} else
XFS_SB_UNLOCK(mp, s);
}
}
/* /*
* Create the initial contents of a shortform attribute list. * Create the initial contents of a shortform attribute list.
*/ */
int void
xfs_attr_shortform_create(xfs_da_args_t *args) xfs_attr_shortform_create(xfs_da_args_t *args)
{ {
xfs_attr_sf_hdr_t *hdr; xfs_attr_sf_hdr_t *hdr;
@ -148,29 +196,37 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
hdr->count = 0; hdr->count = 0;
INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr));
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
return(0);
} }
/* /*
* Add a name/value pair to the shortform attribute list. * Add a name/value pair to the shortform attribute list.
* Overflow from the inode has already been checked for. * Overflow from the inode has already been checked for.
*/ */
int void
xfs_attr_shortform_add(xfs_da_args_t *args) xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
{ {
xfs_attr_shortform_t *sf; xfs_attr_shortform_t *sf;
xfs_attr_sf_entry_t *sfe; xfs_attr_sf_entry_t *sfe;
int i, offset, size; int i, offset, size;
xfs_mount_t *mp;
xfs_inode_t *dp; xfs_inode_t *dp;
xfs_ifork_t *ifp; xfs_ifork_t *ifp;
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
dp->i_d.di_forkoff = forkoff;
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
dp->i_afp->if_ext_max =
XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
ifp = dp->i_afp; ifp = dp->i_afp;
ASSERT(ifp->if_flags & XFS_IFINLINE); ASSERT(ifp->if_flags & XFS_IFINLINE);
sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
sfe = &sf->list[0]; sfe = &sf->list[0];
for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
#ifdef DEBUG
if (sfe->namelen != args->namelen) if (sfe->namelen != args->namelen)
continue; continue;
if (memcmp(args->name, sfe->nameval, args->namelen) != 0) if (memcmp(args->name, sfe->nameval, args->namelen) != 0)
@ -181,7 +237,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args)
if (((args->flags & ATTR_ROOT) != 0) != if (((args->flags & ATTR_ROOT) != 0) !=
((sfe->flags & XFS_ATTR_ROOT) != 0)) ((sfe->flags & XFS_ATTR_ROOT) != 0))
continue; continue;
return(XFS_ERROR(EEXIST)); ASSERT(0);
#endif
} }
offset = (char *)sfe - (char *)sf; offset = (char *)sfe - (char *)sf;
@ -200,11 +257,11 @@ xfs_attr_shortform_add(xfs_da_args_t *args)
INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
return(0); xfs_sbversion_add_attr2(mp, args->trans);
} }
/* /*
* Remove a name from the shortform attribute list structure. * Remove an attribute from the shortform attribute list structure.
*/ */
int int
xfs_attr_shortform_remove(xfs_da_args_t *args) xfs_attr_shortform_remove(xfs_da_args_t *args)
@ -212,17 +269,16 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
xfs_attr_shortform_t *sf; xfs_attr_shortform_t *sf;
xfs_attr_sf_entry_t *sfe; xfs_attr_sf_entry_t *sfe;
int base, size=0, end, totsize, i; int base, size=0, end, totsize, i;
xfs_mount_t *mp;
xfs_inode_t *dp; xfs_inode_t *dp;
/*
* Remove the attribute.
*/
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
base = sizeof(xfs_attr_sf_hdr_t); base = sizeof(xfs_attr_sf_hdr_t);
sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
sfe = &sf->list[0]; sfe = &sf->list[0];
for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); end = INT_GET(sf->hdr.count, ARCH_CONVERT);
sfe = XFS_ATTR_SF_NEXTENTRY(sfe), for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe),
base += size, i++) { base += size, i++) {
size = XFS_ATTR_SF_ENTSIZE(sfe); size = XFS_ATTR_SF_ENTSIZE(sfe);
if (sfe->namelen != args->namelen) if (sfe->namelen != args->namelen)
@ -237,19 +293,51 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
continue; continue;
break; break;
} }
if (i == INT_GET(sf->hdr.count, ARCH_CONVERT)) if (i == end)
return(XFS_ERROR(ENOATTR)); return(XFS_ERROR(ENOATTR));
/*
* Fix up the attribute fork data, covering the hole
*/
end = base + size; end = base + size;
totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
if (end != totsize) { if (end != totsize)
memmove(&((char *)sf)[base], &((char *)sf)[end], memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
totsize - end);
}
INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); INT_MOD(sf->hdr.count, ARCH_CONVERT, -1);
INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size);
xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); /*
* Fix up the start offset of the attribute fork
*/
totsize -= size;
if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname) {
/*
* Last attribute now removed, revert to original
* inode format making all literal area available
* to the data fork once more.
*/
xfs_idestroy_fork(dp, XFS_ATTR_FORK);
dp->i_d.di_forkoff = 0;
dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
ASSERT(dp->i_d.di_anextents == 0);
ASSERT(dp->i_afp == NULL);
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
} else {
xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
ASSERT(dp->i_d.di_forkoff);
ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname);
dp->i_afp->if_ext_max =
XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
xfs_trans_log_inode(args->trans, dp,
XFS_ILOG_CORE | XFS_ILOG_ADATA);
}
xfs_sbversion_add_attr2(mp, args->trans);
return(0); return(0);
} }
@ -561,7 +649,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
/* /*
* Sort the entries on hash then entno. * Sort the entries on hash then entno.
*/ */
qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare); xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare);
/* /*
* Re-find our place IN THE SORTED LIST. * Re-find our place IN THE SORTED LIST.
@ -649,14 +737,16 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
+ name_loc->namelen + name_loc->namelen
+ INT_GET(name_loc->valuelen, ARCH_CONVERT); + INT_GET(name_loc->valuelen, ARCH_CONVERT);
} }
return( bytes < XFS_IFORK_ASIZE(dp) ); if (bytes == sizeof(struct xfs_attr_sf_hdr))
return(-1);
return(xfs_attr_shortform_bytesfit(dp, bytes));
} }
/* /*
* Convert a leaf attribute list to shortform attribute list * Convert a leaf attribute list to shortform attribute list
*/ */
int int
xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args) xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
{ {
xfs_attr_leafblock_t *leaf; xfs_attr_leafblock_t *leaf;
xfs_attr_leaf_entry_t *entry; xfs_attr_leaf_entry_t *entry;
@ -683,9 +773,25 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args)
error = xfs_da_shrink_inode(args, 0, bp); error = xfs_da_shrink_inode(args, 0, bp);
if (error) if (error)
goto out; goto out;
error = xfs_attr_shortform_create(args);
if (error) if (forkoff == -1) {
/*
* Last attribute was removed, revert to original
* inode format making all literal area available
* to the data fork once more.
*/
xfs_idestroy_fork(dp, XFS_ATTR_FORK);
dp->i_d.di_forkoff = 0;
dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
ASSERT(dp->i_d.di_anextents == 0);
ASSERT(dp->i_afp == NULL);
dp->i_df.if_ext_max =
XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
goto out; goto out;
}
xfs_attr_shortform_create(args);
/* /*
* Copy the attributes * Copy the attributes
@ -713,7 +819,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args)
nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT);
nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0);
xfs_attr_shortform_add(&nargs); xfs_attr_shortform_add(&nargs, forkoff);
} }
error = 0; error = 0;
@ -898,7 +1004,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
ASSERT((args->index >= 0) ASSERT((args->index >= 0)
&& (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr; hdr = &leaf->hdr;
entsize = xfs_attr_leaf_newentsize(args, entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
args->trans->t_mountp->m_sb.sb_blocksize, NULL); args->trans->t_mountp->m_sb.sb_blocksize, NULL);
/* /*
@ -995,13 +1101,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
mp = args->trans->t_mountp; mp = args->trans->t_mountp;
ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
ASSERT(INT_GET(map->size, ARCH_CONVERT) ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
>= xfs_attr_leaf_newentsize(args, xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, NULL)); mp->m_sb.sb_blocksize, NULL));
ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
INT_MOD(map->size, ARCH_CONVERT, INT_MOD(map->size, ARCH_CONVERT,
-xfs_attr_leaf_newentsize(args, mp->m_sb.sb_blocksize, &tmp)); -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, &tmp));
INT_SET(entry->nameidx, ARCH_CONVERT, INT_SET(entry->nameidx, ARCH_CONVERT,
INT_GET(map->base, ARCH_CONVERT) INT_GET(map->base, ARCH_CONVERT)
+ INT_GET(map->size, ARCH_CONVERT)); + INT_GET(map->size, ARCH_CONVERT));
@ -1357,8 +1464,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
half = (max+1) * sizeof(*entry); half = (max+1) * sizeof(*entry);
half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
+ INT_GET(hdr2->usedbytes, ARCH_CONVERT) + INT_GET(hdr2->usedbytes, ARCH_CONVERT)
+ xfs_attr_leaf_newentsize(state->args, + xfs_attr_leaf_newentsize(
state->blocksize, NULL); state->args->namelen,
state->args->valuelen,
state->blocksize, NULL);
half /= 2; half /= 2;
lastdelta = state->blocksize; lastdelta = state->blocksize;
entry = &leaf1->entries[0]; entry = &leaf1->entries[0];
@ -1370,9 +1479,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
*/ */
if (count == blk1->index) { if (count == blk1->index) {
tmp = totallen + sizeof(*entry) + tmp = totallen + sizeof(*entry) +
xfs_attr_leaf_newentsize(state->args, xfs_attr_leaf_newentsize(
state->blocksize, state->args->namelen,
NULL); state->args->valuelen,
state->blocksize, NULL);
if (XFS_ATTR_ABS(half - tmp) > lastdelta) if (XFS_ATTR_ABS(half - tmp) > lastdelta)
break; break;
lastdelta = XFS_ATTR_ABS(half - tmp); lastdelta = XFS_ATTR_ABS(half - tmp);
@ -1408,9 +1518,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
totallen -= count * sizeof(*entry); totallen -= count * sizeof(*entry);
if (foundit) { if (foundit) {
totallen -= sizeof(*entry) + totallen -= sizeof(*entry) +
xfs_attr_leaf_newentsize(state->args, xfs_attr_leaf_newentsize(
state->blocksize, state->args->namelen,
NULL); state->args->valuelen,
state->blocksize, NULL);
} }
*countarg = count; *countarg = count;
@ -2253,17 +2364,17 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
* a "local" or a "remote" attribute. * a "local" or a "remote" attribute.
*/ */
int int
xfs_attr_leaf_newentsize(xfs_da_args_t *args, int blocksize, int *local) xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
{ {
int size; int size;
size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(args->namelen, args->valuelen); size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen);
if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) {
if (local) { if (local) {
*local = 1; *local = 1;
} }
} else { } else {
size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(args->namelen); size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen);
if (local) { if (local) {
*local = 0; *local = 0;
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ATTR_LEAF_H__ #ifndef __XFS_ATTR_LEAF_H__
#define __XFS_ATTR_LEAF_H__ #define __XFS_ATTR_LEAF_H__
@ -146,65 +132,58 @@ typedef struct xfs_attr_leaf_name_remote xfs_attr_leaf_name_remote_t;
/* /*
* Cast typed pointers for "local" and "remote" name/value structs. * Cast typed pointers for "local" and "remote" name/value structs.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_REMOTE)
xfs_attr_leaf_name_remote_t *
xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx);
#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \ #define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \
xfs_attr_leaf_name_remote(leafp,idx) xfs_attr_leaf_name_remote(leafp,idx)
#else static inline xfs_attr_leaf_name_remote_t *
#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) /* remote name struct ptr */ \ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
((xfs_attr_leaf_name_remote_t *) \ {
&((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) return (xfs_attr_leaf_name_remote_t *) &((char *)
#endif (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_LOCAL) }
xfs_attr_leaf_name_local_t *
xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx);
#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
xfs_attr_leaf_name_local(leafp,idx) xfs_attr_leaf_name_local(leafp,idx)
#else static inline xfs_attr_leaf_name_local_t *
#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) /* local name struct ptr */ \ xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
((xfs_attr_leaf_name_local_t *) \ {
&((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) return (xfs_attr_leaf_name_local_t *) &((char *)
#endif (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME) }
char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx);
#define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx) #define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx)
#else static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
#define XFS_ATTR_LEAF_NAME(leafp,idx) /* generic name struct ptr */ \ {
(&((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) return (&((char *)
#endif (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]);
}
/* /*
* Calculate total bytes used (including trailing pad for alignment) for * Calculate total bytes used (including trailing pad for alignment) for
* a "local" name/value structure, a "remote" name/value structure, and * a "local" name/value structure, a "remote" name/value structure, and
* a pointer which might be either. * a pointer which might be either.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_REMOTE)
int xfs_attr_leaf_entsize_remote(int nlen);
#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \ #define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \
xfs_attr_leaf_entsize_remote(nlen) xfs_attr_leaf_entsize_remote(nlen)
#else static inline int xfs_attr_leaf_entsize_remote(int nlen)
#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) /* space for remote struct */ \ {
(((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
#endif }
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL)
int xfs_attr_leaf_entsize_local(int nlen, int vlen);
#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \ #define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \
xfs_attr_leaf_entsize_local(nlen,vlen) xfs_attr_leaf_entsize_local(nlen,vlen)
#else static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) /* space for local struct */ \ {
(((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + \ return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
#endif }
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX)
int xfs_attr_leaf_entsize_local_max(int bsize);
#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \ #define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \
xfs_attr_leaf_entsize_local_max(bsize) xfs_attr_leaf_entsize_local_max(bsize)
#else static inline int xfs_attr_leaf_entsize_local_max(int bsize)
#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) /* max local struct size */ \ {
(((bsize) >> 1) + ((bsize) >> 2)) return (((bsize) >> 1) + ((bsize) >> 2));
#endif }
/*======================================================================== /*========================================================================
@ -237,23 +216,25 @@ typedef struct xfs_attr_inactive_list {
*========================================================================*/ *========================================================================*/
/* /*
* Internal routines when dirsize < XFS_LITINO(mp). * Internal routines when attribute fork size < XFS_LITINO(mp).
*/ */
int xfs_attr_shortform_create(struct xfs_da_args *args); void xfs_attr_shortform_create(struct xfs_da_args *args);
int xfs_attr_shortform_add(struct xfs_da_args *add); void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
int xfs_attr_shortform_lookup(struct xfs_da_args *args); int xfs_attr_shortform_lookup(struct xfs_da_args *args);
int xfs_attr_shortform_getvalue(struct xfs_da_args *args); int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
int xfs_attr_shortform_remove(struct xfs_da_args *remove); int xfs_attr_shortform_remove(struct xfs_da_args *args);
int xfs_attr_shortform_list(struct xfs_attr_list_context *context); int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp);
int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
/* /*
* Internal routines when dirsize == XFS_LBSIZE(mp). * Internal routines when attribute fork size == XFS_LBSIZE(mp).
*/ */
int xfs_attr_leaf_to_node(struct xfs_da_args *args); int xfs_attr_leaf_to_node(struct xfs_da_args *args);
int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp,
struct xfs_da_args *args); struct xfs_da_args *args, int forkoff);
int xfs_attr_leaf_clearflag(struct xfs_da_args *args); int xfs_attr_leaf_clearflag(struct xfs_da_args *args);
int xfs_attr_leaf_setflag(struct xfs_da_args *args); int xfs_attr_leaf_setflag(struct xfs_da_args *args);
int xfs_attr_leaf_flipflags(xfs_da_args_t *args); int xfs_attr_leaf_flipflags(xfs_da_args_t *args);
@ -289,7 +270,7 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count);
int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp,
struct xfs_dabuf *leaf2_bp); struct xfs_dabuf *leaf2_bp);
int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize, int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
int *local); int *local);
int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp); int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_ATTR_SF_H__ #ifndef __XFS_ATTR_SF_H__
#define __XFS_ATTR_SF_H__ #define __XFS_ATTR_SF_H__
@ -71,38 +57,17 @@ typedef struct xfs_attr_sf_sort {
char *name; /* name value, pointer into buffer */ char *name; /* name value, pointer into buffer */
} xfs_attr_sf_sort_t; } xfs_attr_sf_sort_t;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME)
int xfs_attr_sf_entsize_byname(int nlen, int vlen);
#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) \
xfs_attr_sf_entsize_byname(nlen,vlen)
#else
#define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)) (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
#endif
#define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE)
int xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep);
#define XFS_ATTR_SF_ENTSIZE(sfep) xfs_attr_sf_entsize(sfep)
#else
#define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_NEXTENTRY)
xfs_attr_sf_entry_t *xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep);
#define XFS_ATTR_SF_NEXTENTRY(sfep) xfs_attr_sf_nextentry(sfep)
#else
#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
((xfs_attr_sf_entry_t *) \ ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_TOTSIZE)
int xfs_attr_sf_totsize(struct xfs_inode *dp);
#define XFS_ATTR_SF_TOTSIZE(dp) xfs_attr_sf_totsize(dp)
#else
#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
(INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) (INT_GET(((xfs_attr_shortform_t *) \
#endif ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
#if defined(XFS_ATTR_TRACE) #if defined(XFS_ATTR_TRACE)
/* /*

View file

@ -1,34 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* 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/
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "xfs.h" #include "xfs.h"

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BEHAVIOR_H__ #ifndef __XFS_BEHAVIOR_H__
#define __XFS_BEHAVIOR_H__ #define __XFS_BEHAVIOR_H__

View file

@ -1,45 +1,29 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* XFS bit manipulation routines, used in non-realtime code.
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_buf_item.h" #include "xfs_buf_item.h"
/*
* XFS bit manipulation routines, used in non-realtime code.
*/
#ifndef HAVE_ARCH_HIGHBIT #ifndef HAVE_ARCH_HIGHBIT
/* /*

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BIT_H__ #ifndef __XFS_BIT_H__
#define __XFS_BIT_H__ #define __XFS_BIT_H__
@ -39,30 +25,26 @@
/* /*
* masks with n high/low bits set, 32-bit values & 64-bit values * masks with n high/low bits set, 32-bit values & 64-bit values
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32HI)
__uint32_t xfs_mask32hi(int n);
#define XFS_MASK32HI(n) xfs_mask32hi(n) #define XFS_MASK32HI(n) xfs_mask32hi(n)
#else static inline __uint32_t xfs_mask32hi(int n)
#define XFS_MASK32HI(n) ((__uint32_t)-1 << (32 - (n))) {
#endif return (__uint32_t)-1 << (32 - (n));
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64HI) }
__uint64_t xfs_mask64hi(int n);
#define XFS_MASK64HI(n) xfs_mask64hi(n) #define XFS_MASK64HI(n) xfs_mask64hi(n)
#else static inline __uint64_t xfs_mask64hi(int n)
#define XFS_MASK64HI(n) ((__uint64_t)-1 << (64 - (n))) {
#endif return (__uint64_t)-1 << (64 - (n));
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32LO) }
__uint32_t xfs_mask32lo(int n);
#define XFS_MASK32LO(n) xfs_mask32lo(n) #define XFS_MASK32LO(n) xfs_mask32lo(n)
#else static inline __uint32_t xfs_mask32lo(int n)
#define XFS_MASK32LO(n) (((__uint32_t)1 << (n)) - 1) {
#endif return ((__uint32_t)1 << (n)) - 1;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64LO) }
__uint64_t xfs_mask64lo(int n);
#define XFS_MASK64LO(n) xfs_mask64lo(n) #define XFS_MASK64LO(n) xfs_mask64lo(n)
#else static inline __uint64_t xfs_mask64lo(int n)
#define XFS_MASK64LO(n) (((__uint64_t)1 << (n)) - 1) {
#endif return ((__uint64_t)1 << (n)) - 1;
}
/* Get high bit set out of 32-bit argument, -1 if none set */ /* Get high bit set out of 32-bit argument, -1 if none set */
extern int xfs_highbit32(__uint32_t v); extern int xfs_highbit32(__uint32_t v);

View file

@ -1,68 +1,53 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_da_btree.h"
#include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_btree.h"
#include "xfs_dmapi.h"
#include "xfs_mount.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h" #include "xfs_itable.h"
#include "xfs_inode_item.h"
#include "xfs_extfree_item.h" #include "xfs_extfree_item.h"
#include "xfs_alloc.h" #include "xfs_alloc.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_da_btree.h"
#include "xfs_dir_leaf.h" #include "xfs_dir_leaf.h"
#include "xfs_bit.h" #include "xfs_attr_leaf.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
@ -438,6 +423,12 @@ xfs_bmap_count_leaves(
int numrecs, int numrecs,
int *count); int *count);
STATIC int
xfs_bmap_disk_count_leaves(
xfs_bmbt_rec_t *frp,
int numrecs,
int *count);
/* /*
* Bmap internal routines. * Bmap internal routines.
*/ */
@ -2772,8 +2763,8 @@ xfs_bmap_btree_to_extents(
ASSERT(ifp->if_flags & XFS_IFEXTENTS); ASSERT(ifp->if_flags & XFS_IFEXTENTS);
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
rblock = ifp->if_broot; rblock = ifp->if_broot;
ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) == 1); ASSERT(be16_to_cpu(rblock->bb_level) == 1);
ASSERT(INT_GET(rblock->bb_numrecs, ARCH_CONVERT) == 1); ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1);
mp = ip->i_mount; mp = ip->i_mount;
pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes);
@ -3216,11 +3207,11 @@ xfs_bmap_extents_to_btree(
* Fill in the root. * Fill in the root.
*/ */
block = ifp->if_broot; block = ifp->if_broot;
INT_SET(block->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
INT_SET(block->bb_level, ARCH_CONVERT, 1); block->bb_level = cpu_to_be16(1);
INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); block->bb_numrecs = cpu_to_be16(1);
INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); block->bb_leftsib = cpu_to_be64(NULLDFSBNO);
INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); block->bb_rightsib = cpu_to_be64(NULLDFSBNO);
/* /*
* Need a cursor. Can't allocate until bb_level is filled in. * Need a cursor. Can't allocate until bb_level is filled in.
*/ */
@ -3273,10 +3264,10 @@ xfs_bmap_extents_to_btree(
* Fill in the child block. * Fill in the child block.
*/ */
ablock = XFS_BUF_TO_BMBT_BLOCK(abp); ablock = XFS_BUF_TO_BMBT_BLOCK(abp);
INT_SET(ablock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
ablock->bb_level = 0; ablock->bb_level = 0;
INT_SET(ablock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
INT_SET(ablock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); arp = XFS_BMAP_REC_IADDR(ablock, 1, cur);
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) { for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) {
@ -3286,8 +3277,8 @@ xfs_bmap_extents_to_btree(
arp++; cnt++; arp++; cnt++;
} }
} }
INT_SET(ablock->bb_numrecs, ARCH_CONVERT, cnt); ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork));
ASSERT(INT_GET(ablock->bb_numrecs, ARCH_CONVERT) == XFS_IFORK_NEXTENTS(ip, whichfork)); ablock->bb_numrecs = cpu_to_be16(cnt);
/* /*
* Fill in the root key and pointer. * Fill in the root key and pointer.
*/ */
@ -3301,7 +3292,7 @@ xfs_bmap_extents_to_btree(
* the root is at the right level. * the root is at the right level.
*/ */
xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS); xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS);
xfs_bmbt_log_recs(cur, abp, 1, INT_GET(ablock->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs));
ASSERT(*curp == NULL); ASSERT(*curp == NULL);
*curp = cur; *curp = cur;
*logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork); *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork);
@ -3336,6 +3327,29 @@ xfs_bmap_insert_exlist(
xfs_bmbt_set_all(&base[to], new); xfs_bmbt_set_all(&base[to], new);
} }
/*
* Helper routine to reset inode di_forkoff field when switching
* attribute fork from local to extent format - we reset it where
* possible to make space available for inline data fork extents.
*/
STATIC void
xfs_bmap_forkoff_reset(
xfs_mount_t *mp,
xfs_inode_t *ip,
int whichfork)
{
if (whichfork == XFS_ATTR_FORK &&
(ip->i_d.di_format != XFS_DINODE_FMT_DEV) &&
(ip->i_d.di_format != XFS_DINODE_FMT_UUID) &&
((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) {
ip->i_d.di_forkoff = mp->m_attroffset >> 3;
ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) /
(uint)sizeof(xfs_bmbt_rec_t);
ip->i_afp->if_ext_max = XFS_IFORK_ASIZE(ip) /
(uint)sizeof(xfs_bmbt_rec_t);
}
}
/* /*
* Convert a local file to an extents file. * Convert a local file to an extents file.
* This code is out of bounds for data forks of regular files, * This code is out of bounds for data forks of regular files,
@ -3403,6 +3417,7 @@ xfs_bmap_local_to_extents(
memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data,
ifp->if_bytes); ifp->if_bytes);
xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
xfs_iext_realloc(ip, 1, whichfork); xfs_iext_realloc(ip, 1, whichfork);
ep = ifp->if_u1.if_extents; ep = ifp->if_u1.if_extents;
@ -3413,8 +3428,10 @@ xfs_bmap_local_to_extents(
XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip,
XFS_TRANS_DQ_BCOUNT, 1L); XFS_TRANS_DQ_BCOUNT, 1L);
flags |= XFS_ILOG_FEXT(whichfork); flags |= XFS_ILOG_FEXT(whichfork);
} else } else {
ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0);
xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork);
}
ifp->if_flags &= ~XFS_IFINLINE; ifp->if_flags &= ~XFS_IFINLINE;
ifp->if_flags |= XFS_IFEXTENTS; ifp->if_flags |= XFS_IFEXTENTS;
XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
@ -3796,22 +3813,24 @@ xfs_bunmap_trace(
int /* error code */ int /* error code */
xfs_bmap_add_attrfork( xfs_bmap_add_attrfork(
xfs_inode_t *ip, /* incore inode pointer */ xfs_inode_t *ip, /* incore inode pointer */
int rsvd) /* OK to allocated reserved blocks in trans */ int size, /* space new attribute needs */
int rsvd) /* xact may use reserved blks */
{ {
int blks; /* space reservation */
int committed; /* xaction was committed */
int error; /* error return value */
xfs_fsblock_t firstblock; /* 1st block/ag allocated */ xfs_fsblock_t firstblock; /* 1st block/ag allocated */
xfs_bmap_free_t flist; /* freed extent list */ xfs_bmap_free_t flist; /* freed extent list */
int logflags; /* logging flags */
xfs_mount_t *mp; /* mount structure */ xfs_mount_t *mp; /* mount structure */
unsigned long s; /* spinlock spl value */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
unsigned long s; /* spinlock spl value */
int blks; /* space reservation */
int version = 1; /* superblock attr version */
int committed; /* xaction was committed */
int logflags; /* logging flags */
int error; /* error return value */
ASSERT(XFS_IFORK_Q(ip) == 0);
ASSERT(ip->i_df.if_ext_max == ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t)); XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t));
if (XFS_IFORK_Q(ip))
return 0;
mp = ip->i_mount; mp = ip->i_mount;
ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); ASSERT(!XFS_NOT_DQATTACHED(mp, ip));
tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK); tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK);
@ -3853,7 +3872,11 @@ xfs_bmap_add_attrfork(
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
case XFS_DINODE_FMT_EXTENTS: case XFS_DINODE_FMT_EXTENTS:
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
ip->i_d.di_forkoff = mp->m_attroffset >> 3; ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size);
if (!ip->i_d.di_forkoff)
ip->i_d.di_forkoff = mp->m_attroffset >> 3;
else if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR))
version = 2;
break; break;
default: default:
ASSERT(0); ASSERT(0);
@ -3890,12 +3913,22 @@ xfs_bmap_add_attrfork(
xfs_trans_log_inode(tp, ip, logflags); xfs_trans_log_inode(tp, ip, logflags);
if (error) if (error)
goto error2; goto error2;
if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { if (!XFS_SB_VERSION_HASATTR(&mp->m_sb) ||
(!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2)) {
__int64_t sbfields = 0;
s = XFS_SB_LOCK(mp); s = XFS_SB_LOCK(mp);
if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) {
XFS_SB_VERSION_ADDATTR(&mp->m_sb); XFS_SB_VERSION_ADDATTR(&mp->m_sb);
sbfields |= XFS_SB_VERSIONNUM;
}
if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2) {
XFS_SB_VERSION_ADDATTR2(&mp->m_sb);
sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
}
if (sbfields) {
XFS_SB_UNLOCK(mp, s); XFS_SB_UNLOCK(mp, s);
xfs_mod_sb(tp, XFS_SB_VERSIONNUM); xfs_mod_sb(tp, sbfields);
} else } else
XFS_SB_UNLOCK(mp, s); XFS_SB_UNLOCK(mp, s);
} }
@ -3988,13 +4021,19 @@ xfs_bmap_compute_maxlevels(
* (a signed 32-bit number, xfs_extnum_t), or by di_anextents * (a signed 32-bit number, xfs_extnum_t), or by di_anextents
* (a signed 16-bit number, xfs_aextnum_t). * (a signed 16-bit number, xfs_aextnum_t).
*/ */
maxleafents = (whichfork == XFS_DATA_FORK) ? MAXEXTNUM : MAXAEXTNUM; if (whichfork == XFS_DATA_FORK) {
maxleafents = MAXEXTNUM;
sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ?
mp->m_attroffset : XFS_BMDR_SPACE_CALC(MINDBTPTRS);
} else {
maxleafents = MAXAEXTNUM;
sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ?
mp->m_sb.sb_inodesize - mp->m_attroffset :
XFS_BMDR_SPACE_CALC(MINABTPTRS);
}
maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0);
minleafrecs = mp->m_bmap_dmnr[0]; minleafrecs = mp->m_bmap_dmnr[0];
minnoderecs = mp->m_bmap_dmnr[1]; minnoderecs = mp->m_bmap_dmnr[1];
sz = (whichfork == XFS_DATA_FORK) ?
mp->m_attroffset :
mp->m_sb.sb_inodesize - mp->m_attroffset;
maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0);
maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;
for (level = 1; maxblocks > 1; level++) { for (level = 1; maxblocks > 1; level++) {
if (maxblocks <= maxrootrecs) if (maxblocks <= maxrootrecs)
@ -4332,8 +4371,8 @@ xfs_bmap_read_extents(
/* /*
* Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
*/ */
ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); level = be16_to_cpu(block->bb_level);
level = INT_GET(block->bb_level, ARCH_CONVERT); ASSERT(level > 0);
pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount);
@ -4376,7 +4415,7 @@ xfs_bmap_read_extents(
xfs_extnum_t num_recs; xfs_extnum_t num_recs;
num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); num_recs = be16_to_cpu(block->bb_numrecs);
if (unlikely(i + num_recs > room)) { if (unlikely(i + num_recs > room)) {
ASSERT(i + num_recs <= room); ASSERT(i + num_recs <= room);
xfs_fs_cmn_err(CE_WARN, ip->i_mount, xfs_fs_cmn_err(CE_WARN, ip->i_mount,
@ -4393,7 +4432,7 @@ xfs_bmap_read_extents(
/* /*
* Read-ahead the next leaf block, if any. * Read-ahead the next leaf block, if any.
*/ */
nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); nextbno = be64_to_cpu(block->bb_rightsib);
if (nextbno != NULLFSBLOCK) if (nextbno != NULLFSBLOCK)
xfs_btree_reada_bufl(mp, nextbno, 1); xfs_btree_reada_bufl(mp, nextbno, 1);
/* /*
@ -4650,7 +4689,7 @@ xfs_bmapi(
} }
if (wr && *firstblock == NULLFSBLOCK) { if (wr && *firstblock == NULLFSBLOCK) {
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
minleft = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
else else
minleft = 1; minleft = 1;
} else } else
@ -5692,12 +5731,13 @@ xfs_getbmap(
out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff); out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff);
out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount); out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
ASSERT(map[i].br_startblock != DELAYSTARTBLOCK); ASSERT(map[i].br_startblock != DELAYSTARTBLOCK);
if (prealloced && if (map[i].br_startblock == HOLESTARTBLOCK &&
map[i].br_startblock == HOLESTARTBLOCK && ((prealloced && out.bmv_offset + out.bmv_length == bmvend) ||
out.bmv_offset + out.bmv_length == bmvend) { whichfork == XFS_ATTR_FORK )) {
/* /*
* came to hole at end of file * came to hole at end of file or the end of
*/ attribute fork
*/
goto unlock_and_return; goto unlock_and_return;
} else { } else {
out.bmv_block = out.bmv_block =
@ -5927,10 +5967,10 @@ xfs_check_block(
xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */
xfs_bmbt_key_t *prevp, *keyp; xfs_bmbt_key_t *prevp, *keyp;
ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); ASSERT(be16_to_cpu(block->bb_level) > 0);
prevp = NULL; prevp = NULL;
for( i = 1; i <= INT_GET(block->bb_numrecs, ARCH_CONVERT);i++) { for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) {
dmxr = mp->m_bmap_dmxr[0]; dmxr = mp->m_bmap_dmxr[0];
if (root) { if (root) {
@ -5955,7 +5995,7 @@ xfs_check_block(
pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
xfs_bmbt, block, i, dmxr); xfs_bmbt, block, i, dmxr);
} }
for (j = i+1; j <= INT_GET(block->bb_numrecs, ARCH_CONVERT); j++) { for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
if (root) { if (root) {
thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz);
} else { } else {
@ -6008,8 +6048,8 @@ xfs_bmap_check_leaf_extents(
/* /*
* Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
*/ */
ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); level = be16_to_cpu(block->bb_level);
level = INT_GET(block->bb_level, ARCH_CONVERT); ASSERT(level > 0);
xfs_check_block(block, mp, 1, ifp->if_broot_bytes); xfs_check_block(block, mp, 1, ifp->if_broot_bytes);
pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
@ -6069,13 +6109,13 @@ xfs_bmap_check_leaf_extents(
xfs_extnum_t num_recs; xfs_extnum_t num_recs;
num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); num_recs = be16_to_cpu(block->bb_numrecs);
/* /*
* Read-ahead the next leaf block, if any. * Read-ahead the next leaf block, if any.
*/ */
nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); nextbno = be64_to_cpu(block->bb_rightsib);
/* /*
* Check all the extents to make sure they are OK. * Check all the extents to make sure they are OK.
@ -6131,7 +6171,7 @@ error0:
xfs_trans_brelse(NULL, bp); xfs_trans_brelse(NULL, bp);
error_norelse: error_norelse:
cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents", cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents",
i, __FUNCTION__); __FUNCTION__, i);
panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__); panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__);
return; return;
} }
@ -6172,8 +6212,8 @@ xfs_bmap_count_blocks(
* Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out.
*/ */
block = ifp->if_broot; block = ifp->if_broot;
ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); level = be16_to_cpu(block->bb_level);
level = INT_GET(block->bb_level, ARCH_CONVERT); ASSERT(level > 0);
pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO);
ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount);
@ -6218,14 +6258,14 @@ xfs_bmap_count_tree(
if (--level) { if (--level) {
/* Not at node above leafs, count this level of nodes */ /* Not at node above leafs, count this level of nodes */
nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); nextbno = be64_to_cpu(block->bb_rightsib);
while (nextbno != NULLFSBLOCK) { while (nextbno != NULLFSBLOCK) {
if ((error = xfs_btree_read_bufl(mp, tp, nextbno, if ((error = xfs_btree_read_bufl(mp, tp, nextbno,
0, &nbp, XFS_BMAP_BTREE_REF))) 0, &nbp, XFS_BMAP_BTREE_REF)))
return error; return error;
*count += 1; *count += 1;
nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp);
nextbno = INT_GET(nextblock->bb_rightsib, ARCH_CONVERT); nextbno = be64_to_cpu(nextblock->bb_rightsib);
xfs_trans_brelse(tp, nbp); xfs_trans_brelse(tp, nbp);
} }
@ -6244,11 +6284,11 @@ xfs_bmap_count_tree(
} else { } else {
/* count all level 1 nodes and their leaves */ /* count all level 1 nodes and their leaves */
for (;;) { for (;;) {
nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); nextbno = be64_to_cpu(block->bb_rightsib);
numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); numrecs = be16_to_cpu(block->bb_numrecs);
frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]); xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]);
if (unlikely(xfs_bmap_count_leaves(frp, numrecs, count) < 0)) { if (unlikely(xfs_bmap_disk_count_leaves(frp, numrecs, count) < 0)) {
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
@ -6279,6 +6319,22 @@ xfs_bmap_count_leaves(
{ {
int b; int b;
for ( b = 1; b <= numrecs; b++, frp++)
*count += xfs_bmbt_get_blockcount(frp);
return 0;
}
/*
* Count leaf blocks given a pointer to an extent list originally in btree format.
*/
int
xfs_bmap_disk_count_leaves(
xfs_bmbt_rec_t *frp,
int numrecs,
int *count)
{
int b;
for ( b = 1; b <= numrecs; b++, frp++) for ( b = 1; b <= numrecs; b++, frp++)
*count += xfs_bmbt_disk_get_blockcount(frp); *count += xfs_bmbt_disk_get_blockcount(frp);
return 0; return 0;

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BMAP_H__ #ifndef __XFS_BMAP_H__
#define __XFS_BMAP_H__ #define __XFS_BMAP_H__
@ -77,12 +63,11 @@ typedef struct xfs_bmap_free
/* combine contig. space */ /* combine contig. space */
#define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */ #define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAPI_AFLAG)
int xfs_bmapi_aflag(int w);
#define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w) #define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w)
#else static inline int xfs_bmapi_aflag(int w)
#define XFS_BMAPI_AFLAG(w) ((w) == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0) {
#endif return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0);
}
/* /*
* Special values for xfs_bmbt_irec_t br_startblock field. * Special values for xfs_bmbt_irec_t br_startblock field.
@ -90,14 +75,12 @@ int xfs_bmapi_aflag(int w);
#define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL) #define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL)
#define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL) #define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT)
void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp);
#define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp) #define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp)
#else static inline void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp)
#define XFS_BMAP_INIT(flp,fbp) \ {
((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \ ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \
(flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK) (flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK);
#endif }
/* /*
* Argument structure for xfs_bmap_alloc. * Argument structure for xfs_bmap_alloc.
@ -156,7 +139,8 @@ xfs_bmap_trace_exlist(
int /* error code */ int /* error code */
xfs_bmap_add_attrfork( xfs_bmap_add_attrfork(
struct xfs_inode *ip, /* incore inode pointer */ struct xfs_inode *ip, /* incore inode pointer */
int rsvd); /* flag for reserved block allocation */ int size, /* space needed for new attribute */
int rsvd); /* flag for reserved block allocation */
/* /*
* Add the extent to the list of extents to be free at transaction end. * Add the extent to the list of extents to be free at transaction end.

View file

@ -1,41 +1,26 @@
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,20 +28,19 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h"
#include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_alloc.h"
#include "xfs_btree.h" #include "xfs_btree.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
#include "xfs_itable.h" #include "xfs_itable.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h"
#include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h"
#include "xfs_alloc.h"
#include "xfs_bit.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_quota.h" #include "xfs_quota.h"
@ -382,7 +366,7 @@ xfs_bmbt_delrec(
return 0; return 0;
} }
block = xfs_bmbt_get_block(cur, level, &bp); block = xfs_bmbt_get_block(cur, level, &bp);
numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); numrecs = be16_to_cpu(block->bb_numrecs);
#ifdef DEBUG #ifdef DEBUG
if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { if ((error = xfs_btree_check_lblock(cur, block, level, bp))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@ -427,7 +411,7 @@ xfs_bmbt_delrec(
} }
} }
numrecs--; numrecs--;
INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); block->bb_numrecs = cpu_to_be16(numrecs);
xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS);
/* /*
* We're at the root level. * We're at the root level.
@ -463,8 +447,8 @@ xfs_bmbt_delrec(
*stat = 1; *stat = 1;
return 0; return 0;
} }
rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); rbno = be64_to_cpu(block->bb_rightsib);
lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); lbno = be64_to_cpu(block->bb_leftsib);
/* /*
* One child of root, need to get a chance to copy its contents * One child of root, need to get a chance to copy its contents
* into the root and delete it. Can't go up to next level, * into the root and delete it. Can't go up to next level,
@ -508,15 +492,15 @@ xfs_bmbt_delrec(
goto error0; goto error0;
} }
#endif #endif
bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); bno = be64_to_cpu(right->bb_leftsib);
if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= if (be16_to_cpu(right->bb_numrecs) - 1 >=
XFS_BMAP_BLOCK_IMINRECS(level, cur)) { XFS_BMAP_BLOCK_IMINRECS(level, cur)) {
if ((error = xfs_bmbt_lshift(tcur, level, &i))) { if ((error = xfs_bmbt_lshift(tcur, level, &i))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
goto error0; goto error0;
} }
if (i) { if (i) {
ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= ASSERT(be16_to_cpu(block->bb_numrecs) >=
XFS_BMAP_BLOCK_IMINRECS(level, tcur)); XFS_BMAP_BLOCK_IMINRECS(level, tcur));
xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
tcur = NULL; tcur = NULL;
@ -533,7 +517,7 @@ xfs_bmbt_delrec(
return 0; return 0;
} }
} }
rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); rrecs = be16_to_cpu(right->bb_numrecs);
if (lbno != NULLFSBLOCK) { if (lbno != NULLFSBLOCK) {
i = xfs_btree_firstrec(tcur, level); i = xfs_btree_firstrec(tcur, level);
XFS_WANT_CORRUPTED_GOTO(i == 1, error0); XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
@ -564,15 +548,15 @@ xfs_bmbt_delrec(
goto error0; goto error0;
} }
#endif #endif
bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); bno = be64_to_cpu(left->bb_rightsib);
if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= if (be16_to_cpu(left->bb_numrecs) - 1 >=
XFS_BMAP_BLOCK_IMINRECS(level, cur)) { XFS_BMAP_BLOCK_IMINRECS(level, cur)) {
if ((error = xfs_bmbt_rshift(tcur, level, &i))) { if ((error = xfs_bmbt_rshift(tcur, level, &i))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
goto error0; goto error0;
} }
if (i) { if (i) {
ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= ASSERT(be16_to_cpu(block->bb_numrecs) >=
XFS_BMAP_BLOCK_IMINRECS(level, tcur)); XFS_BMAP_BLOCK_IMINRECS(level, tcur));
xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
tcur = NULL; tcur = NULL;
@ -583,14 +567,14 @@ xfs_bmbt_delrec(
return 0; return 0;
} }
} }
lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); lrecs = be16_to_cpu(left->bb_numrecs);
} }
xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
tcur = NULL; tcur = NULL;
mp = cur->bc_mp; mp = cur->bc_mp;
ASSERT(bno != NULLFSBLOCK); ASSERT(bno != NULLFSBLOCK);
if (lbno != NULLFSBLOCK && if (lbno != NULLFSBLOCK &&
lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
rbno = bno; rbno = bno;
right = block; right = block;
rbp = bp; rbp = bp;
@ -605,7 +589,7 @@ xfs_bmbt_delrec(
goto error0; goto error0;
} }
} else if (rbno != NULLFSBLOCK && } else if (rbno != NULLFSBLOCK &&
rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= rrecs + be16_to_cpu(block->bb_numrecs) <=
XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
lbno = bno; lbno = bno;
left = block; left = block;
@ -620,7 +604,7 @@ xfs_bmbt_delrec(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
goto error0; goto error0;
} }
lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); lrecs = be16_to_cpu(left->bb_numrecs);
} else { } else {
if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@ -630,8 +614,8 @@ xfs_bmbt_delrec(
*stat = 1; *stat = 1;
return 0; return 0;
} }
numlrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); numlrecs = be16_to_cpu(left->bb_numrecs);
numrrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); numrrecs = be16_to_cpu(right->bb_numrecs);
if (level > 0) { if (level > 0) {
lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur);
lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur);
@ -655,12 +639,12 @@ xfs_bmbt_delrec(
memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); memcpy(lrp, rrp, numrrecs * sizeof(*lrp));
xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs);
} }
INT_MOD(left->bb_numrecs, ARCH_CONVERT, numrrecs); be16_add(&left->bb_numrecs, numrrecs);
left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ left->bb_rightsib = right->bb_rightsib;
xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS);
if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { if (be64_to_cpu(left->bb_rightsib) != NULLDFSBNO) {
if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, if ((error = xfs_btree_read_bufl(mp, cur->bc_tp,
INT_GET(left->bb_rightsib, ARCH_CONVERT), be64_to_cpu(left->bb_rightsib),
0, &rrbp, XFS_BMAP_BTREE_REF))) { 0, &rrbp, XFS_BMAP_BTREE_REF))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
goto error0; goto error0;
@ -670,7 +654,7 @@ xfs_bmbt_delrec(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
goto error0; goto error0;
} }
INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); rrblock->bb_leftsib = cpu_to_be64(lbno);
xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB);
} }
xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1,
@ -727,7 +711,7 @@ xfs_bmbt_get_rec(
if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) if ((error = xfs_btree_check_lblock(cur, block, 0, bp)))
return error; return error;
#endif #endif
if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
*stat = 0; *stat = 0;
return 0; return 0;
} }
@ -788,7 +772,7 @@ xfs_bmbt_insrec(
} }
XFS_STATS_INC(xs_bmbt_insrec); XFS_STATS_INC(xs_bmbt_insrec);
block = xfs_bmbt_get_block(cur, level, &bp); block = xfs_bmbt_get_block(cur, level, &bp);
numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); numrecs = be16_to_cpu(block->bb_numrecs);
#ifdef DEBUG #ifdef DEBUG
if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { if ((error = xfs_btree_check_lblock(cur, block, level, bp))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@ -870,7 +854,7 @@ xfs_bmbt_insrec(
} }
} }
} }
numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); numrecs = be16_to_cpu(block->bb_numrecs);
if (level > 0) { if (level > 0) {
kp = XFS_BMAP_KEY_IADDR(block, 1, cur); kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
pp = XFS_BMAP_PTR_IADDR(block, 1, cur); pp = XFS_BMAP_PTR_IADDR(block, 1, cur);
@ -897,7 +881,7 @@ xfs_bmbt_insrec(
kp[ptr - 1] = key; kp[ptr - 1] = key;
INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop);
numrecs++; numrecs++;
INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); block->bb_numrecs = cpu_to_be16(numrecs);
xfs_bmbt_log_keys(cur, bp, ptr, numrecs); xfs_bmbt_log_keys(cur, bp, ptr, numrecs);
xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs);
} else { } else {
@ -906,7 +890,7 @@ xfs_bmbt_insrec(
(numrecs - ptr + 1) * sizeof(*rp)); (numrecs - ptr + 1) * sizeof(*rp));
rp[ptr - 1] = *recp; rp[ptr - 1] = *recp;
numrecs++; numrecs++;
INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); block->bb_numrecs = cpu_to_be16(numrecs);
xfs_bmbt_log_recs(cur, bp, ptr, numrecs); xfs_bmbt_log_recs(cur, bp, ptr, numrecs);
} }
xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS);
@ -971,7 +955,7 @@ xfs_bmbt_killroot(
/* /*
* Give up if the root has multiple children. * Give up if the root has multiple children.
*/ */
if (INT_GET(block->bb_numrecs, ARCH_CONVERT) != 1) { if (be16_to_cpu(block->bb_numrecs) != 1) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
return 0; return 0;
} }
@ -982,37 +966,37 @@ xfs_bmbt_killroot(
*/ */
cbp = cur->bc_bufs[level - 1]; cbp = cur->bc_bufs[level - 1];
cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); cblock = XFS_BUF_TO_BMBT_BLOCK(cbp);
if (INT_GET(cblock->bb_numrecs, ARCH_CONVERT) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { if (be16_to_cpu(cblock->bb_numrecs) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
return 0; return 0;
} }
ASSERT(INT_GET(cblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); ASSERT(be64_to_cpu(cblock->bb_leftsib) == NULLDFSBNO);
ASSERT(INT_GET(cblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); ASSERT(be64_to_cpu(cblock->bb_rightsib) == NULLDFSBNO);
ip = cur->bc_private.b.ip; ip = cur->bc_private.b.ip;
ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork);
ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) ==
XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes));
i = (int)(INT_GET(cblock->bb_numrecs, ARCH_CONVERT) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); i = (int)(be16_to_cpu(cblock->bb_numrecs) - XFS_BMAP_BLOCK_IMAXRECS(level, cur));
if (i) { if (i) {
xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork);
block = ifp->if_broot; block = ifp->if_broot;
} }
INT_MOD(block->bb_numrecs, ARCH_CONVERT, i); be16_add(&block->bb_numrecs, i);
ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) == INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); ASSERT(block->bb_numrecs == cblock->bb_numrecs);
kp = XFS_BMAP_KEY_IADDR(block, 1, cur); kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur);
memcpy(kp, ckp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); memcpy(kp, ckp, be16_to_cpu(block->bb_numrecs) * sizeof(*kp));
pp = XFS_BMAP_PTR_IADDR(block, 1, cur); pp = XFS_BMAP_PTR_IADDR(block, 1, cur);
cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur);
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) {
if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
} }
#endif #endif
memcpy(pp, cpp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); memcpy(pp, cpp, be16_to_cpu(block->bb_numrecs) * sizeof(*pp));
xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, 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--; ip->i_d.di_nblocks--;
@ -1020,7 +1004,7 @@ xfs_bmbt_killroot(
XFS_TRANS_DQ_BCOUNT, -1L); XFS_TRANS_DQ_BCOUNT, -1L);
xfs_trans_binval(cur->bc_tp, cbp); xfs_trans_binval(cur->bc_tp, cbp);
cur->bc_bufs[level - 1] = NULL; cur->bc_bufs[level - 1] = NULL;
INT_MOD(block->bb_level, ARCH_CONVERT, -1); be16_add(&block->bb_level, -1);
xfs_trans_log_inode(cur->bc_tp, ip, xfs_trans_log_inode(cur->bc_tp, ip,
XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork));
cur->bc_nlevels--; cur->bc_nlevels--;
@ -1176,7 +1160,7 @@ xfs_bmbt_lookup(
else else
krbase = XFS_BMAP_REC_IADDR(block, 1, cur); krbase = XFS_BMAP_REC_IADDR(block, 1, cur);
low = 1; low = 1;
if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { if (!(high = be16_to_cpu(block->bb_numrecs))) {
ASSERT(level == 0); ASSERT(level == 0);
cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE;
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
@ -1223,8 +1207,8 @@ xfs_bmbt_lookup(
* If ge search and we went off the end of the block, but it's * If ge search and we went off the end of the block, but it's
* not the last block, we're in the wrong block. * not the last block, we're in the wrong block.
*/ */
if (dir == XFS_LOOKUP_GE && keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && if (dir == XFS_LOOKUP_GE && keyno > be16_to_cpu(block->bb_numrecs) &&
INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { be64_to_cpu(block->bb_rightsib) != NULLDFSBNO) {
cur->bc_ptrs[0] = keyno; cur->bc_ptrs[0] = keyno;
if ((error = xfs_bmbt_increment(cur, 0, &i))) { if ((error = xfs_bmbt_increment(cur, 0, &i))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@ -1239,7 +1223,7 @@ xfs_bmbt_lookup(
else if (dir == XFS_LOOKUP_LE && diff > 0) else if (dir == XFS_LOOKUP_LE && diff > 0)
keyno--; keyno--;
cur->bc_ptrs[0] = keyno; cur->bc_ptrs[0] = keyno;
if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
} else { } else {
@ -1296,7 +1280,7 @@ xfs_bmbt_lshift(
return error; return error;
} }
#endif #endif
if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { if (be64_to_cpu(right->bb_leftsib) == NULLDFSBNO) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
@ -1307,7 +1291,7 @@ xfs_bmbt_lshift(
return 0; return 0;
} }
mp = cur->bc_mp; mp = cur->bc_mp;
if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(right->bb_leftsib), 0,
&lbp, XFS_BMAP_BTREE_REF))) { &lbp, XFS_BMAP_BTREE_REF))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
@ -1317,12 +1301,12 @@ xfs_bmbt_lshift(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { if (be16_to_cpu(left->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
} }
lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; lrecs = be16_to_cpu(left->bb_numrecs) + 1;
if (level > 0) { if (level > 0) {
lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur);
rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
@ -1344,7 +1328,7 @@ xfs_bmbt_lshift(
*lrp = *rrp; *lrp = *rrp;
xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs);
} }
INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); left->bb_numrecs = cpu_to_be16(lrecs);
xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS);
#ifdef DEBUG #ifdef DEBUG
if (level > 0) if (level > 0)
@ -1352,8 +1336,8 @@ xfs_bmbt_lshift(
else else
xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp);
#endif #endif
rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; rrecs = be16_to_cpu(right->bb_numrecs) - 1;
INT_SET(right->bb_numrecs, ARCH_CONVERT, rrecs); right->bb_numrecs = cpu_to_be16(rrecs);
xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS);
if (level > 0) { if (level > 0) {
#ifdef DEBUG #ifdef DEBUG
@ -1430,18 +1414,18 @@ xfs_bmbt_rshift(
return error; return error;
} }
#endif #endif
if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { if (be64_to_cpu(left->bb_rightsib) == NULLDFSBNO) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
} }
if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
} }
mp = cur->bc_mp; mp = cur->bc_mp;
if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(left->bb_rightsib), 0,
&rbp, XFS_BMAP_BTREE_REF))) { &rbp, XFS_BMAP_BTREE_REF))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
@ -1451,26 +1435,26 @@ xfs_bmbt_rshift(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { if (be16_to_cpu(right->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
} }
if (level > 0) { if (level > 0) {
lkp = XFS_BMAP_KEY_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); lkp = XFS_BMAP_KEY_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
lpp = XFS_BMAP_PTR_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); lpp = XFS_BMAP_PTR_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); rpp = XFS_BMAP_PTR_IADDR(right, 1, cur);
#ifdef DEBUG #ifdef DEBUG
for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) {
if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
} }
#endif #endif
memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
#ifdef DEBUG #ifdef DEBUG
if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
@ -1479,21 +1463,21 @@ xfs_bmbt_rshift(
#endif #endif
*rkp = *lkp; *rkp = *lkp;
*rpp = *lpp; /* INT_: direct copy */ *rpp = *lpp; /* INT_: direct copy */
xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
} else { } else {
lrp = XFS_BMAP_REC_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); lrp = XFS_BMAP_REC_IADDR(left, be16_to_cpu(left->bb_numrecs), cur);
rrp = XFS_BMAP_REC_IADDR(right, 1, cur); rrp = XFS_BMAP_REC_IADDR(right, 1, cur);
memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
*rrp = *lrp; *rrp = *lrp;
xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
INT_SET(key.br_startoff, ARCH_CONVERT, INT_SET(key.br_startoff, ARCH_CONVERT,
xfs_bmbt_disk_get_startoff(rrp)); xfs_bmbt_disk_get_startoff(rrp));
rkp = &key; rkp = &key;
} }
INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); be16_add(&left->bb_numrecs, -1);
xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS);
INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); be16_add(&right->bb_numrecs, 1);
#ifdef DEBUG #ifdef DEBUG
if (level > 0) if (level > 0)
xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1);
@ -1624,47 +1608,47 @@ xfs_bmbt_split(
return error; return error;
} }
#endif #endif
INT_SET(right->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); right->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
right->bb_level = left->bb_level; /* INT_: direct copy */ right->bb_level = left->bb_level;
INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2);
if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && if ((be16_to_cpu(left->bb_numrecs) & 1) &&
cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1)
INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); be16_add(&right->bb_numrecs, 1);
i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1;
if (level > 0) { if (level > 0) {
lkp = XFS_BMAP_KEY_IADDR(left, i, cur); lkp = XFS_BMAP_KEY_IADDR(left, i, cur);
lpp = XFS_BMAP_PTR_IADDR(left, i, cur); lpp = XFS_BMAP_PTR_IADDR(left, i, cur);
rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); rkp = XFS_BMAP_KEY_IADDR(right, 1, cur);
rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); rpp = XFS_BMAP_PTR_IADDR(right, 1, cur);
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) {
if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
} }
#endif #endif
memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp));
memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp));
xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT);
} else { } else {
lrp = XFS_BMAP_REC_IADDR(left, i, cur); lrp = XFS_BMAP_REC_IADDR(left, i, cur);
rrp = XFS_BMAP_REC_IADDR(right, 1, cur); rrp = XFS_BMAP_REC_IADDR(right, 1, cur);
memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp);
} }
INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ right->bb_rightsib = left->bb_rightsib;
INT_SET(left->bb_rightsib, ARCH_CONVERT, args.fsbno); left->bb_rightsib = cpu_to_be64(args.fsbno);
INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); right->bb_leftsib = cpu_to_be64(lbno);
xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS);
xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { if (be64_to_cpu(right->bb_rightsib) != NULLDFSBNO) {
if ((error = xfs_btree_read_bufl(args.mp, args.tp, if ((error = xfs_btree_read_bufl(args.mp, args.tp,
INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, be64_to_cpu(right->bb_rightsib), 0, &rrbp,
XFS_BMAP_BTREE_REF))) { XFS_BMAP_BTREE_REF))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
@ -1674,12 +1658,12 @@ xfs_bmbt_split(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.fsbno); rrblock->bb_leftsib = cpu_to_be64(args.fsbno);
xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB);
} }
if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) {
xfs_btree_setbuf(cur, level, rbp); xfs_btree_setbuf(cur, level, rbp);
cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs);
} }
if (level + 1 < cur->bc_nlevels) { if (level + 1 < cur->bc_nlevels) {
if ((error = xfs_btree_dup_cursor(cur, curp))) { if ((error = xfs_btree_dup_cursor(cur, curp))) {
@ -1751,18 +1735,18 @@ xfs_bmdr_to_bmbt(
xfs_bmbt_key_t *tkp; xfs_bmbt_key_t *tkp;
xfs_bmbt_ptr_t *tpp; xfs_bmbt_ptr_t *tpp;
INT_SET(rblock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
rblock->bb_level = dblock->bb_level; /* both in on-disk format */ rblock->bb_level = dblock->bb_level;
ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); ASSERT(be16_to_cpu(rblock->bb_level) > 0);
rblock->bb_numrecs = dblock->bb_numrecs;/* both in on-disk format */ rblock->bb_numrecs = dblock->bb_numrecs;
INT_SET(rblock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
INT_SET(rblock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); dmxr = be16_to_cpu(dblock->bb_numrecs);
memcpy(tkp, fkp, sizeof(*fkp) * dmxr); memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */
} }
@ -1805,7 +1789,7 @@ xfs_bmbt_decrement(
return error; return error;
} }
#endif #endif
if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { if (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
@ -1837,7 +1821,7 @@ xfs_bmbt_decrement(
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs);
} }
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 1; *stat = 1;
@ -2123,12 +2107,12 @@ xfs_bmbt_increment(
return error; return error;
} }
#endif #endif
if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 1; *stat = 1;
return 0; return 0;
} }
if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { if (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO) {
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*stat = 0; *stat = 0;
return 0; return 0;
@ -2141,7 +2125,7 @@ xfs_bmbt_increment(
return error; return error;
} }
#endif #endif
if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs))
break; break;
if (lev < cur->bc_nlevels - 1) if (lev < cur->bc_nlevels - 1)
xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA);
@ -2403,23 +2387,23 @@ xfs_bmbt_newroot(
bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0);
cblock = XFS_BUF_TO_BMBT_BLOCK(bp); cblock = XFS_BUF_TO_BMBT_BLOCK(bp);
*cblock = *block; *cblock = *block;
INT_MOD(block->bb_level, ARCH_CONVERT, +1); be16_add(&block->bb_level, 1);
INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); block->bb_numrecs = cpu_to_be16(1);
cur->bc_nlevels++; cur->bc_nlevels++;
cur->bc_ptrs[level + 1] = 1; cur->bc_ptrs[level + 1] = 1;
kp = XFS_BMAP_KEY_IADDR(block, 1, cur); kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur);
memcpy(ckp, kp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); memcpy(ckp, kp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*kp));
cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur);
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) {
if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) {
XFS_BMBT_TRACE_CURSOR(cur, ERROR); XFS_BMBT_TRACE_CURSOR(cur, ERROR);
return error; return error;
} }
} }
#endif #endif
memcpy(cpp, pp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp));
#ifdef DEBUG #ifdef DEBUG
if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno,
level))) { level))) {
@ -2428,7 +2412,7 @@ xfs_bmbt_newroot(
} }
#endif #endif
INT_SET(*pp, ARCH_CONVERT, args.fsbno); INT_SET(*pp, ARCH_CONVERT, args.fsbno);
xfs_iroot_realloc(cur->bc_private.b.ip, 1 - INT_GET(cblock->bb_numrecs, ARCH_CONVERT), xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs),
cur->bc_private.b.whichfork); cur->bc_private.b.whichfork);
xfs_btree_setbuf(cur, level, bp); xfs_btree_setbuf(cur, level, bp);
/* /*
@ -2436,8 +2420,8 @@ xfs_bmbt_newroot(
* the root is at the right level. * the root is at the right level.
*/ */
xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS);
xfs_bmbt_log_keys(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_keys(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs));
xfs_bmbt_log_ptrs(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); xfs_bmbt_log_ptrs(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs));
XFS_BMBT_TRACE_CURSOR(cur, EXIT); XFS_BMBT_TRACE_CURSOR(cur, EXIT);
*logflags |= *logflags |=
XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork);
@ -2705,18 +2689,18 @@ xfs_bmbt_to_bmdr(
xfs_bmbt_key_t *tkp; xfs_bmbt_key_t *tkp;
xfs_bmbt_ptr_t *tpp; xfs_bmbt_ptr_t *tpp;
ASSERT(INT_GET(rblock->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC); ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC);
ASSERT(INT_GET(rblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO);
ASSERT(INT_GET(rblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); ASSERT(be64_to_cpu(rblock->bb_rightsib) == NULLDFSBNO);
ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); ASSERT(be16_to_cpu(rblock->bb_level) > 0);
dblock->bb_level = rblock->bb_level; /* both in on-disk format */ dblock->bb_level = rblock->bb_level;
dblock->bb_numrecs = rblock->bb_numrecs;/* both in on-disk format */ dblock->bb_numrecs = rblock->bb_numrecs;
dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0);
fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen);
tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr);
dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); dmxr = be16_to_cpu(dblock->bb_numrecs);
memcpy(tkp, fkp, sizeof(*fkp) * dmxr); memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000,2002-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BMAP_BTREE_H__ #ifndef __XFS_BMAP_BTREE_H__
#define __XFS_BMAP_BTREE_H__ #define __XFS_BMAP_BTREE_H__
@ -42,10 +28,9 @@ struct xfs_inode;
/* /*
* Bmap root header, on-disk form only. * Bmap root header, on-disk form only.
*/ */
typedef struct xfs_bmdr_block typedef struct xfs_bmdr_block {
{ __be16 bb_level; /* 0 is a leaf */
__uint16_t bb_level; /* 0 is a leaf */ __be16 bb_numrecs; /* current # of data records */
__uint16_t bb_numrecs; /* current # of data records */
} xfs_bmdr_block_t; } xfs_bmdr_block_t;
/* /*
@ -114,31 +99,31 @@ typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
(((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
#define DSTARTBLOCKMASK \ #define DSTARTBLOCKMASK \
(((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLSTARTBLOCK)
int isnullstartblock(xfs_fsblock_t x);
#define ISNULLSTARTBLOCK(x) isnullstartblock(x) #define ISNULLSTARTBLOCK(x) isnullstartblock(x)
#else static inline int isnullstartblock(xfs_fsblock_t x)
#define ISNULLSTARTBLOCK(x) (((x) & STARTBLOCKMASK) == STARTBLOCKMASK) {
#endif return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLDSTARTBLOCK) }
int isnulldstartblock(xfs_dfsbno_t x);
#define ISNULLDSTARTBLOCK(x) isnulldstartblock(x) #define ISNULLDSTARTBLOCK(x) isnulldstartblock(x)
#else static inline int isnulldstartblock(xfs_dfsbno_t x)
#define ISNULLDSTARTBLOCK(x) (((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK) {
#endif return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_NULLSTARTBLOCK) }
xfs_fsblock_t nullstartblock(int k);
#define NULLSTARTBLOCK(k) nullstartblock(k) #define NULLSTARTBLOCK(k) nullstartblock(k)
#else static inline xfs_fsblock_t nullstartblock(int k)
#define NULLSTARTBLOCK(k) \ {
((ASSERT(k < (1 << STARTBLOCKVALBITS))), (STARTBLOCKMASK | (k))) ASSERT(k < (1 << STARTBLOCKVALBITS));
#endif return STARTBLOCKMASK | (k);
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_STARTBLOCKVAL) }
xfs_filblks_t startblockval(xfs_fsblock_t x);
#define STARTBLOCKVAL(x) startblockval(x) #define STARTBLOCKVAL(x) startblockval(x)
#else static inline xfs_filblks_t startblockval(xfs_fsblock_t x)
#define STARTBLOCKVAL(x) ((xfs_filblks_t)((x) & ~STARTBLOCKMASK)) {
#endif return (xfs_filblks_t)((x) & ~STARTBLOCKMASK);
}
/* /*
* Possible extent formats. * Possible extent formats.
@ -159,14 +144,9 @@ typedef enum {
/* /*
* Extent state and extent format macros. * Extent state and extent format macros.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTFMT_INODE ) #define XFS_EXTFMT_INODE(x) \
xfs_exntfmt_t xfs_extfmt_inode(struct xfs_inode *ip); (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
#define XFS_EXTFMT_INODE(x) xfs_extfmt_inode(x) XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
#else
#define XFS_EXTFMT_INODE(x) \
(XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \
XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
#endif
#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) #define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN)
/* /*
@ -192,248 +172,110 @@ typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */
/* btree block header type */ /* btree block header type */
typedef struct xfs_btree_lblock xfs_bmbt_block_t; typedef struct xfs_btree_lblock xfs_bmbt_block_t;
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BMBT_BLOCK) #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))
xfs_bmbt_block_t *xfs_buf_to_bmbt_block(struct xfs_buf *bp);
#define XFS_BUF_TO_BMBT_BLOCK(bp) xfs_buf_to_bmbt_block(bp)
#else
#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)(XFS_BUF_PTR(bp)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_DSIZE) #define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
int xfs_bmap_rblock_dsize(int lev, struct xfs_btree_cur *cur); #define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) xfs_bmap_rblock_dsize(lev,cur) #define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
#else
#define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_ISIZE)
int xfs_bmap_rblock_isize(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) xfs_bmap_rblock_isize(lev,cur)
#else
#define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \
((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \
(cur)->bc_private.b.whichfork)->if_broot_bytes) (cur)->bc_private.b.whichfork)->if_broot_bytes)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_IBLOCK_SIZE)
int xfs_bmap_iblock_size(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_IBLOCK_SIZE(lev,cur) xfs_bmap_iblock_size(lev,cur)
#else
#define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DSIZE) #define XFS_BMAP_BLOCK_DSIZE(lev,cur) \
int xfs_bmap_block_dsize(int lev, struct xfs_btree_cur *cur); (((lev) == (cur)->bc_nlevels - 1 ? \
#define XFS_BMAP_BLOCK_DSIZE(lev,cur) xfs_bmap_block_dsize(lev,cur) XFS_BMAP_RBLOCK_DSIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
#else #define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
#define XFS_BMAP_BLOCK_DSIZE(lev,cur) \ (((lev) == (cur)->bc_nlevels - 1 ? \
((lev) == (cur)->bc_nlevels - 1 ? \ XFS_BMAP_RBLOCK_ISIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur)))
XFS_BMAP_RBLOCK_DSIZE(lev,cur) : \
XFS_BMAP_IBLOCK_SIZE(lev,cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_ISIZE)
int xfs_bmap_block_isize(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_BLOCK_ISIZE(lev,cur) xfs_bmap_block_isize(lev,cur)
#else
#define XFS_BMAP_BLOCK_ISIZE(lev,cur) \
((lev) == (cur)->bc_nlevels - 1 ? \
XFS_BMAP_RBLOCK_ISIZE(lev,cur) : \
XFS_BMAP_IBLOCK_SIZE(lev,cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMAXRECS)
int xfs_bmap_block_dmaxrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) xfs_bmap_block_dmaxrecs(lev,cur)
#else
#define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ #define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \
((lev) == (cur)->bc_nlevels - 1 ? \ (((lev) == (cur)->bc_nlevels - 1 ? \
XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \
xfs_bmdr, (lev) == 0) : \ xfs_bmdr, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMAXRECS)
int xfs_bmap_block_imaxrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) xfs_bmap_block_imaxrecs(lev,cur)
#else
#define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \ #define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \
((lev) == (cur)->bc_nlevels - 1 ? \ (((lev) == (cur)->bc_nlevels - 1 ? \
XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
xfs_bmbt, (lev) == 0) : \ xfs_bmbt, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMINRECS)
int xfs_bmap_block_dminrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) xfs_bmap_block_dminrecs(lev,cur)
#else
#define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \ #define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \
((lev) == (cur)->bc_nlevels - 1 ? \ (((lev) == (cur)->bc_nlevels - 1 ? \
XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur),\
xfs_bmdr, (lev) == 0) : \ xfs_bmdr, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMINRECS)
int xfs_bmap_block_iminrecs(int lev, struct xfs_btree_cur *cur);
#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) xfs_bmap_block_iminrecs(lev,cur)
#else
#define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \ #define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \
((lev) == (cur)->bc_nlevels - 1 ? \ (((lev) == (cur)->bc_nlevels - 1 ? \
XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\
xfs_bmbt, (lev) == 0) : \ xfs_bmbt, (lev) == 0) : \
((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_DADDR) #define XFS_BMAP_REC_DADDR(bb,i,cur) \
xfs_bmbt_rec_t * (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \
xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); be16_to_cpu((bb)->bb_level), cur), \
#define XFS_BMAP_REC_DADDR(bb,i,cur) xfs_bmap_rec_daddr(bb,i,cur) xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
#else be16_to_cpu((bb)->bb_level), cur)))
#define XFS_BMAP_REC_DADDR(bb,i,cur) \ #define XFS_BMAP_REC_IADDR(bb,i,cur) \
XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ be16_to_cpu((bb)->bb_level), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) be16_to_cpu((bb)->bb_level), cur)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_IADDR)
xfs_bmbt_rec_t *
xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
#define XFS_BMAP_REC_IADDR(bb,i,cur) xfs_bmap_rec_iaddr(bb,i,cur)
#else
#define XFS_BMAP_REC_IADDR(bb,i,cur) \
XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_DADDR) #define XFS_BMAP_KEY_DADDR(bb,i,cur) \
xfs_bmbt_key_t * (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \
xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); be16_to_cpu((bb)->bb_level), cur), \
#define XFS_BMAP_KEY_DADDR(bb,i,cur) xfs_bmap_key_daddr(bb,i,cur) xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
#else be16_to_cpu((bb)->bb_level), cur)))
#define XFS_BMAP_KEY_DADDR(bb,i,cur) \ #define XFS_BMAP_KEY_IADDR(bb,i,cur) \
XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ be16_to_cpu((bb)->bb_level), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) be16_to_cpu((bb)->bb_level), cur)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_IADDR)
xfs_bmbt_key_t *
xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
#define XFS_BMAP_KEY_IADDR(bb,i,cur) xfs_bmap_key_iaddr(bb,i,cur)
#else
#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_DADDR) #define XFS_BMAP_PTR_DADDR(bb,i,cur) \
xfs_bmbt_ptr_t * (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \
xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); be16_to_cpu((bb)->bb_level), cur), \
#define XFS_BMAP_PTR_DADDR(bb,i,cur) xfs_bmap_ptr_daddr(bb,i,cur) xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
#else be16_to_cpu((bb)->bb_level), cur)))
#define XFS_BMAP_PTR_DADDR(bb,i,cur) \ #define XFS_BMAP_PTR_IADDR(bb,i,cur) \
XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \ (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ be16_to_cpu((bb)->bb_level), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) be16_to_cpu((bb)->bb_level), cur)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_IADDR)
xfs_bmbt_ptr_t *
xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur);
#define XFS_BMAP_PTR_IADDR(bb,i,cur) xfs_bmap_ptr_iaddr(bb,i,cur)
#else
#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \
xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \
INT_GET((bb)->bb_level, ARCH_CONVERT), cur))
#endif
/* /*
* These are to be used when we know the size of the block and * These are to be used when we know the size of the block and
* we don't have a cursor. * we don't have a cursor.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_REC_ADDR)
xfs_bmbt_rec_t *xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz);
#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) xfs_bmap_broot_rec_addr(bb,i,sz)
#else
#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ #define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \
XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) (XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_KEY_ADDR)
xfs_bmbt_key_t *xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz);
#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) xfs_bmap_broot_key_addr(bb,i,sz)
#else
#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ #define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) (XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_PTR_ADDR)
xfs_bmbt_ptr_t *xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz);
#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) xfs_bmap_broot_ptr_addr(bb,i,sz)
#else
#define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ #define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \
XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)))
#endif
#define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs)
#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_NUMRECS)
int xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb);
#define XFS_BMAP_BROOT_NUMRECS(bb) xfs_bmap_broot_numrecs(bb)
#else
#define XFS_BMAP_BROOT_NUMRECS(bb) (INT_GET((bb)->bb_numrecs, ARCH_CONVERT))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_MAXRECS)
int xfs_bmap_broot_maxrecs(int sz);
#define XFS_BMAP_BROOT_MAXRECS(sz) xfs_bmap_broot_maxrecs(sz)
#else
#define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE_CALC)
int xfs_bmap_broot_space_calc(int nrecs);
#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) xfs_bmap_broot_space_calc(nrecs)
#else
#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
((int)(sizeof(xfs_bmbt_block_t) + \ (int)(sizeof(xfs_bmbt_block_t) + \
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))) ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE)
int xfs_bmap_broot_space(xfs_bmdr_block_t *bb);
#define XFS_BMAP_BROOT_SPACE(bb) xfs_bmap_broot_space(bb)
#else
#define XFS_BMAP_BROOT_SPACE(bb) \ #define XFS_BMAP_BROOT_SPACE(bb) \
XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT)) (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs)))
#endif #define XFS_BMDR_SPACE_CALC(nrecs) \
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMDR_SPACE_CALC) (int)(sizeof(xfs_bmdr_block_t) + \
int xfs_bmdr_space_calc(int nrecs); ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))
#define XFS_BMDR_SPACE_CALC(nrecs) xfs_bmdr_space_calc(nrecs)
#else
#define XFS_BMDR_SPACE_CALC(nrecs) \
((int)(sizeof(xfs_bmdr_block_t) + \
((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))))
#endif
/* /*
* Maximum number of bmap btree levels. * Maximum number of bmap btree levels.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BM_MAXLEVELS) #define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)])
int xfs_bm_maxlevels(struct xfs_mount *mp, int w);
#define XFS_BM_MAXLEVELS(mp,w) xfs_bm_maxlevels(mp,w)
#else
#define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[w])
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_SANITY_CHECK) #define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
int xfs_bmap_sanity_check(struct xfs_mount *mp, xfs_bmbt_block_t *bb, (be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \
int level); be16_to_cpu((bb)->bb_level) == level && \
#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ be16_to_cpu((bb)->bb_numrecs) > 0 && \
xfs_bmap_sanity_check(mp,bb,level) be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])
#else
#define XFS_BMAP_SANITY_CHECK(mp,bb,level) \
(INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \
INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \
INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \
INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0])
#endif
#ifdef __KERNEL__ #ifdef __KERNEL__
@ -459,234 +301,84 @@ extern ktrace_t *xfs_bmbt_trace_buf;
/* /*
* Prototypes for xfs_bmap.c to call. * Prototypes for xfs_bmap.c to call.
*/ */
extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int);
void extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *);
xfs_bmdr_to_bmbt( extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *);
xfs_bmdr_block_t *, extern void xfs_bmbt_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
int, extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur,
xfs_bmbt_block_t *, int, struct xfs_buf **bpp);
int); extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_t *r);
extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_t *r);
int extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_t *r);
xfs_bmbt_decrement( extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r);
struct xfs_btree_cur *,
int,
int *);
int
xfs_bmbt_delete(
struct xfs_btree_cur *,
int *);
void
xfs_bmbt_get_all(
xfs_bmbt_rec_t *r,
xfs_bmbt_irec_t *s);
xfs_bmbt_block_t *
xfs_bmbt_get_block(
struct xfs_btree_cur *cur,
int level,
struct xfs_buf **bpp);
xfs_filblks_t
xfs_bmbt_get_blockcount(
xfs_bmbt_rec_t *r);
xfs_fsblock_t
xfs_bmbt_get_startblock(
xfs_bmbt_rec_t *r);
xfs_fileoff_t
xfs_bmbt_get_startoff(
xfs_bmbt_rec_t *r);
xfs_exntst_t
xfs_bmbt_get_state(
xfs_bmbt_rec_t *r);
#ifndef XFS_NATIVE_HOST #ifndef XFS_NATIVE_HOST
void extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
xfs_bmbt_disk_get_all( extern xfs_exntst_t xfs_bmbt_disk_get_state(xfs_bmbt_rec_t *r);
xfs_bmbt_rec_t *r, extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r);
xfs_bmbt_irec_t *s); extern xfs_fsblock_t xfs_bmbt_disk_get_startblock(xfs_bmbt_rec_t *r);
extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r);
xfs_exntst_t
xfs_bmbt_disk_get_state(
xfs_bmbt_rec_t *r);
xfs_filblks_t
xfs_bmbt_disk_get_blockcount(
xfs_bmbt_rec_t *r);
xfs_fsblock_t
xfs_bmbt_disk_get_startblock(
xfs_bmbt_rec_t *r);
xfs_fileoff_t
xfs_bmbt_disk_get_startoff(
xfs_bmbt_rec_t *r);
#else #else
#define xfs_bmbt_disk_get_all(r, s) \ #define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s)
xfs_bmbt_get_all(r, s) #define xfs_bmbt_disk_get_state(r) xfs_bmbt_get_state(r)
#define xfs_bmbt_disk_get_state(r) \ #define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r)
xfs_bmbt_get_state(r) #define xfs_bmbt_disk_get_startblock(r) xfs_bmbt_get_blockcount(r)
#define xfs_bmbt_disk_get_blockcount(r) \ #define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r)
xfs_bmbt_get_blockcount(r)
#define xfs_bmbt_disk_get_startblock(r) \
xfs_bmbt_get_blockcount(r)
#define xfs_bmbt_disk_get_startoff(r) \
xfs_bmbt_get_startoff(r)
#endif /* XFS_NATIVE_HOST */ #endif /* XFS_NATIVE_HOST */
int extern int xfs_bmbt_increment(struct xfs_btree_cur *, int, int *);
xfs_bmbt_increment( extern int xfs_bmbt_insert(struct xfs_btree_cur *, int *);
struct xfs_btree_cur *, extern void xfs_bmbt_log_block(struct xfs_btree_cur *, struct xfs_buf *, int);
int, extern void xfs_bmbt_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int,
int *); int);
extern int xfs_bmbt_lookup_eq(struct xfs_btree_cur *, xfs_fileoff_t,
int xfs_fsblock_t, xfs_filblks_t, int *);
xfs_bmbt_insert( extern int xfs_bmbt_lookup_ge(struct xfs_btree_cur *, xfs_fileoff_t,
struct xfs_btree_cur *, xfs_fsblock_t, xfs_filblks_t, int *);
int *);
void
xfs_bmbt_log_block(
struct xfs_btree_cur *,
struct xfs_buf *,
int);
void
xfs_bmbt_log_recs(
struct xfs_btree_cur *,
struct xfs_buf *,
int,
int);
int
xfs_bmbt_lookup_eq(
struct xfs_btree_cur *,
xfs_fileoff_t,
xfs_fsblock_t,
xfs_filblks_t,
int *);
int
xfs_bmbt_lookup_ge(
struct xfs_btree_cur *,
xfs_fileoff_t,
xfs_fsblock_t,
xfs_filblks_t,
int *);
/* /*
* Give the bmap btree a new root block. Copy the old broot contents * Give the bmap btree a new root block. Copy the old broot contents
* down into a real block and make the broot point to it. * down into a real block and make the broot point to it.
*/ */
int /* error */ extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat);
xfs_bmbt_newroot(
struct xfs_btree_cur *cur, /* btree cursor */
int *logflags, /* logging flags for inode */
int *stat); /* return status - 0 fail */
void extern void xfs_bmbt_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
xfs_bmbt_set_all( extern void xfs_bmbt_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
xfs_bmbt_rec_t *r, xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
xfs_bmbt_irec_t *s); extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_t *r, xfs_filblks_t v);
extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_t *r, xfs_fsblock_t v);
void extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_t *r, xfs_fileoff_t v);
xfs_bmbt_set_allf( extern void xfs_bmbt_set_state(xfs_bmbt_rec_t *r, xfs_exntst_t v);
xfs_bmbt_rec_t *r,
xfs_fileoff_t o,
xfs_fsblock_t b,
xfs_filblks_t c,
xfs_exntst_t v);
void
xfs_bmbt_set_blockcount(
xfs_bmbt_rec_t *r,
xfs_filblks_t v);
void
xfs_bmbt_set_startblock(
xfs_bmbt_rec_t *r,
xfs_fsblock_t v);
void
xfs_bmbt_set_startoff(
xfs_bmbt_rec_t *r,
xfs_fileoff_t v);
void
xfs_bmbt_set_state(
xfs_bmbt_rec_t *r,
xfs_exntst_t v);
#ifndef XFS_NATIVE_HOST #ifndef XFS_NATIVE_HOST
void extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
xfs_bmbt_disk_set_all( extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
xfs_bmbt_rec_t *r, xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
xfs_bmbt_irec_t *s);
void
xfs_bmbt_disk_set_allf(
xfs_bmbt_rec_t *r,
xfs_fileoff_t o,
xfs_fsblock_t b,
xfs_filblks_t c,
xfs_exntst_t v);
#else #else
#define xfs_bmbt_disk_set_all(r, s) \ #define xfs_bmbt_disk_set_all(r, s) xfs_bmbt_set_all(r, s)
xfs_bmbt_set_all(r, s) #define xfs_bmbt_disk_set_allf(r, o, b, c, v) xfs_bmbt_set_allf(r, o, b, c, v)
#define xfs_bmbt_disk_set_allf(r, o, b, c, v) \
xfs_bmbt_set_allf(r, o, b, c, v)
#endif /* XFS_NATIVE_HOST */ #endif /* XFS_NATIVE_HOST */
void extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
xfs_bmbt_to_bmdr( extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t,
xfs_bmbt_block_t *, xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t);
int,
xfs_bmdr_block_t *,
int);
int
xfs_bmbt_update(
struct xfs_btree_cur *,
xfs_fileoff_t,
xfs_fsblock_t,
xfs_filblks_t,
xfs_exntst_t);
#ifdef DEBUG #ifdef DEBUG
/* /*
* Get the data from the pointed-to record. * Get the data from the pointed-to record.
*/ */
int extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *,
xfs_bmbt_get_rec( xfs_fsblock_t *, xfs_filblks_t *,
struct xfs_btree_cur *, xfs_exntst_t *, int *);
xfs_fileoff_t *,
xfs_fsblock_t *,
xfs_filblks_t *,
xfs_exntst_t *,
int *);
#endif #endif
/* /*
* Search an extent list for the extent which includes block * Search an extent list for the extent which includes block
* bno. * bno.
*/ */
xfs_bmbt_rec_t * xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *,
xfs_bmap_do_search_extents( xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *,
xfs_bmbt_rec_t *, xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
xfs_extnum_t,
xfs_extnum_t,
xfs_fileoff_t,
int *,
xfs_extnum_t *,
xfs_bmbt_irec_t *,
xfs_bmbt_irec_t *);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */

View file

@ -1,45 +1,26 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* This file contains common code for the space manager's btree implementations.
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -47,17 +28,16 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_bit.h" #include "xfs_btree.h"
#include "xfs_ialloc.h"
#include "xfs_error.h" #include "xfs_error.h"
/* /*
@ -110,11 +90,14 @@ xfs_btree_maxrecs(
switch (cur->bc_btnum) { switch (cur->bc_btnum) {
case XFS_BTNUM_BNO: case XFS_BTNUM_BNO:
case XFS_BTNUM_CNT: case XFS_BTNUM_CNT:
return (int)XFS_ALLOC_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); return (int)XFS_ALLOC_BLOCK_MAXRECS(
be16_to_cpu(block->bb_h.bb_level), cur);
case XFS_BTNUM_BMAP: case XFS_BTNUM_BMAP:
return (int)XFS_BMAP_BLOCK_IMAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); return (int)XFS_BMAP_BLOCK_IMAXRECS(
be16_to_cpu(block->bb_h.bb_level), cur);
case XFS_BTNUM_INO: case XFS_BTNUM_INO:
return (int)XFS_INOBT_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); return (int)XFS_INOBT_BLOCK_MAXRECS(
be16_to_cpu(block->bb_h.bb_level), cur);
default: default:
ASSERT(0); ASSERT(0);
return 0; return 0;
@ -160,7 +143,7 @@ xfs_btree_check_key(
k1 = ak1; k1 = ak1;
k2 = ak2; k2 = ak2;
ASSERT(INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT)); ASSERT(be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock));
break; break;
} }
case XFS_BTNUM_CNT: { case XFS_BTNUM_CNT: {
@ -169,9 +152,9 @@ xfs_btree_check_key(
k1 = ak1; k1 = ak1;
k2 = ak2; k2 = ak2;
ASSERT(INT_GET(k1->ar_blockcount, ARCH_CONVERT) < INT_GET(k2->ar_blockcount, ARCH_CONVERT) || ASSERT(be32_to_cpu(k1->ar_blockcount) < be32_to_cpu(k2->ar_blockcount) ||
(INT_GET(k1->ar_blockcount, ARCH_CONVERT) == INT_GET(k2->ar_blockcount, ARCH_CONVERT) && (k1->ar_blockcount == k2->ar_blockcount &&
INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT))); be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock)));
break; break;
} }
case XFS_BTNUM_BMAP: { case XFS_BTNUM_BMAP: {
@ -214,16 +197,16 @@ xfs_btree_check_lblock(
mp = cur->bc_mp; mp = cur->bc_mp;
lblock_ok = lblock_ok =
INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
INT_GET(block->bb_level, ARCH_CONVERT) == level && be16_to_cpu(block->bb_level) == level &&
INT_GET(block->bb_numrecs, ARCH_CONVERT) <= be16_to_cpu(block->bb_numrecs) <=
xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
block->bb_leftsib && block->bb_leftsib &&
(INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO || (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO ||
XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_leftsib, ARCH_CONVERT))) && XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) &&
block->bb_rightsib && block->bb_rightsib &&
(INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO || (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO ||
XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_rightsib, ARCH_CONVERT))); XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_rightsib)));
if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK,
XFS_RANDOM_BTREE_CHECK_LBLOCK))) { XFS_RANDOM_BTREE_CHECK_LBLOCK))) {
if (bp) if (bp)
@ -271,8 +254,9 @@ xfs_btree_check_rec(
r1 = ar1; r1 = ar1;
r2 = ar2; r2 = ar2;
ASSERT(INT_GET(r1->ar_startblock, ARCH_CONVERT) + INT_GET(r1->ar_blockcount, ARCH_CONVERT) <= ASSERT(be32_to_cpu(r1->ar_startblock) +
INT_GET(r2->ar_startblock, ARCH_CONVERT)); be32_to_cpu(r1->ar_blockcount) <=
be32_to_cpu(r2->ar_startblock));
break; break;
} }
case XFS_BTNUM_CNT: { case XFS_BTNUM_CNT: {
@ -281,9 +265,9 @@ xfs_btree_check_rec(
r1 = ar1; r1 = ar1;
r2 = ar2; r2 = ar2;
ASSERT(INT_GET(r1->ar_blockcount, ARCH_CONVERT) < INT_GET(r2->ar_blockcount, ARCH_CONVERT) || ASSERT(be32_to_cpu(r1->ar_blockcount) < be32_to_cpu(r2->ar_blockcount) ||
(INT_GET(r1->ar_blockcount, ARCH_CONVERT) == INT_GET(r2->ar_blockcount, ARCH_CONVERT) && (r1->ar_blockcount == r2->ar_blockcount &&
INT_GET(r1->ar_startblock, ARCH_CONVERT) < INT_GET(r2->ar_startblock, ARCH_CONVERT))); be32_to_cpu(r1->ar_startblock) < be32_to_cpu(r2->ar_startblock)));
break; break;
} }
case XFS_BTNUM_BMAP: { case XFS_BTNUM_BMAP: {
@ -331,17 +315,17 @@ xfs_btree_check_sblock(
agbp = cur->bc_private.a.agbp; agbp = cur->bc_private.a.agbp;
agf = XFS_BUF_TO_AGF(agbp); agf = XFS_BUF_TO_AGF(agbp);
agflen = INT_GET(agf->agf_length, ARCH_CONVERT); agflen = be32_to_cpu(agf->agf_length);
sblock_ok = sblock_ok =
INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
INT_GET(block->bb_level, ARCH_CONVERT) == level && be16_to_cpu(block->bb_level) == level &&
INT_GET(block->bb_numrecs, ARCH_CONVERT) <= be16_to_cpu(block->bb_numrecs) <=
xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
(INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK || (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK ||
INT_GET(block->bb_leftsib, ARCH_CONVERT) < agflen) && be32_to_cpu(block->bb_leftsib) < agflen) &&
block->bb_leftsib && block->bb_leftsib &&
(INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK || (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK ||
INT_GET(block->bb_rightsib, ARCH_CONVERT) < agflen) && be32_to_cpu(block->bb_rightsib) < agflen) &&
block->bb_rightsib; block->bb_rightsib;
if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp,
XFS_ERRTAG_BTREE_CHECK_SBLOCK, XFS_ERRTAG_BTREE_CHECK_SBLOCK,
@ -372,7 +356,7 @@ xfs_btree_check_sptr(
XFS_WANT_CORRUPTED_RETURN( XFS_WANT_CORRUPTED_RETURN(
level > 0 && level > 0 &&
ptr != NULLAGBLOCK && ptr != 0 && ptr != NULLAGBLOCK && ptr != 0 &&
ptr < INT_GET(agf->agf_length, ARCH_CONVERT)); ptr < be32_to_cpu(agf->agf_length));
return 0; return 0;
} }
@ -611,15 +595,15 @@ xfs_btree_init_cursor(
case XFS_BTNUM_BNO: case XFS_BTNUM_BNO:
case XFS_BTNUM_CNT: case XFS_BTNUM_CNT:
agf = XFS_BUF_TO_AGF(agbp); agf = XFS_BUF_TO_AGF(agbp);
nlevels = INT_GET(agf->agf_levels[btnum], ARCH_CONVERT); nlevels = be32_to_cpu(agf->agf_levels[btnum]);
break; break;
case XFS_BTNUM_BMAP: case XFS_BTNUM_BMAP:
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
nlevels = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1;
break; break;
case XFS_BTNUM_INO: case XFS_BTNUM_INO:
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
nlevels = INT_GET(agi->agi_level, ARCH_CONVERT); nlevels = be32_to_cpu(agi->agi_level);
break; break;
default: default:
ASSERT(0); ASSERT(0);
@ -683,9 +667,9 @@ xfs_btree_islastblock(
block = xfs_btree_get_block(cur, level, &bp); block = xfs_btree_get_block(cur, level, &bp);
xfs_btree_check_block(cur, block, level, bp); xfs_btree_check_block(cur, block, level, bp);
if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) if (XFS_BTREE_LONG_PTRS(cur->bc_btnum))
return INT_GET(block->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO; return be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO;
else else
return INT_GET(block->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK; return be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK;
} }
/* /*
@ -713,7 +697,7 @@ xfs_btree_lastrec(
/* /*
* Set the ptr value to numrecs, that's the last record/key. * Set the ptr value to numrecs, that's the last record/key.
*/ */
cur->bc_ptrs[level] = INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT); cur->bc_ptrs[level] = be16_to_cpu(block->bb_h.bb_numrecs);
return 1; return 1;
} }
@ -883,38 +867,38 @@ xfs_btree_readahead_core(
case XFS_BTNUM_BNO: case XFS_BTNUM_BNO:
case XFS_BTNUM_CNT: case XFS_BTNUM_CNT:
a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]);
if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(a->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(a->bb_leftsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
INT_GET(a->bb_leftsib, ARCH_CONVERT), 1); be32_to_cpu(a->bb_leftsib), 1);
rval++; rval++;
} }
if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(a->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(a->bb_rightsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
INT_GET(a->bb_rightsib, ARCH_CONVERT), 1); be32_to_cpu(a->bb_rightsib), 1);
rval++; rval++;
} }
break; break;
case XFS_BTNUM_BMAP: case XFS_BTNUM_BMAP:
b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]);
if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(b->bb_leftsib, ARCH_CONVERT) != NULLDFSBNO) { if ((lr & XFS_BTCUR_LEFTRA) && be64_to_cpu(b->bb_leftsib) != NULLDFSBNO) {
xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_leftsib, ARCH_CONVERT), 1); xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_leftsib), 1);
rval++; rval++;
} }
if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(b->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { if ((lr & XFS_BTCUR_RIGHTRA) && be64_to_cpu(b->bb_rightsib) != NULLDFSBNO) {
xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_rightsib, ARCH_CONVERT), 1); xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_rightsib), 1);
rval++; rval++;
} }
break; break;
case XFS_BTNUM_INO: case XFS_BTNUM_INO:
i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]);
if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(i->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
INT_GET(i->bb_leftsib, ARCH_CONVERT), 1); be32_to_cpu(i->bb_leftsib), 1);
rval++; rval++;
} }
if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(i->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
INT_GET(i->bb_rightsib, ARCH_CONVERT), 1); be32_to_cpu(i->bb_rightsib), 1);
rval++; rval++;
} }
break; break;
@ -946,14 +930,14 @@ xfs_btree_setbuf(
return; return;
b = XFS_BUF_TO_BLOCK(bp); b = XFS_BUF_TO_BLOCK(bp);
if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) { if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) {
if (INT_GET(b->bb_u.l.bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO)
cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
if (INT_GET(b->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) if (be64_to_cpu(b->bb_u.l.bb_rightsib) == NULLDFSBNO)
cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
} else { } else {
if (INT_GET(b->bb_u.s.bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) if (be32_to_cpu(b->bb_u.s.bb_leftsib) == NULLAGBLOCK)
cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
if (INT_GET(b->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) if (be32_to_cpu(b->bb_u.s.bb_rightsib) == NULLAGBLOCK)
cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
} }
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BTREE_H__ #ifndef __XFS_BTREE_H__
#define __XFS_BTREE_H__ #define __XFS_BTREE_H__
@ -53,25 +39,23 @@ struct xfs_trans;
/* /*
* Short form header: space allocation btrees. * Short form header: space allocation btrees.
*/ */
typedef struct xfs_btree_sblock typedef struct xfs_btree_sblock {
{ __be32 bb_magic; /* magic number for block type */
__uint32_t bb_magic; /* magic number for block type */ __be16 bb_level; /* 0 is a leaf */
__uint16_t bb_level; /* 0 is a leaf */ __be16 bb_numrecs; /* current # of data records */
__uint16_t bb_numrecs; /* current # of data records */ __be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */
xfs_agblock_t bb_leftsib; /* left sibling block or NULLAGBLOCK */ __be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */
xfs_agblock_t bb_rightsib; /* right sibling block or NULLAGBLOCK */
} xfs_btree_sblock_t; } xfs_btree_sblock_t;
/* /*
* Long form header: bmap btrees. * Long form header: bmap btrees.
*/ */
typedef struct xfs_btree_lblock typedef struct xfs_btree_lblock {
{ __be32 bb_magic; /* magic number for block type */
__uint32_t bb_magic; /* magic number for block type */ __be16 bb_level; /* 0 is a leaf */
__uint16_t bb_level; /* 0 is a leaf */ __be16 bb_numrecs; /* current # of data records */
__uint16_t bb_numrecs; /* current # of data records */ __be64 bb_leftsib; /* left sibling block or NULLDFSBNO */
xfs_dfsbno_t bb_leftsib; /* left sibling block or NULLDFSBNO */ __be64 bb_rightsib; /* right sibling block or NULLDFSBNO */
xfs_dfsbno_t bb_rightsib; /* right sibling block or NULLDFSBNO */
} xfs_btree_lblock_t; } xfs_btree_lblock_t;
/* /*
@ -79,24 +63,23 @@ typedef struct xfs_btree_lblock
*/ */
typedef struct xfs_btree_hdr typedef struct xfs_btree_hdr
{ {
__uint32_t bb_magic; /* magic number for block type */ __be32 bb_magic; /* magic number for block type */
__uint16_t bb_level; /* 0 is a leaf */ __be16 bb_level; /* 0 is a leaf */
__uint16_t bb_numrecs; /* current # of data records */ __be16 bb_numrecs; /* current # of data records */
} xfs_btree_hdr_t; } xfs_btree_hdr_t;
typedef struct xfs_btree_block typedef struct xfs_btree_block {
{
xfs_btree_hdr_t bb_h; /* header */ xfs_btree_hdr_t bb_h; /* header */
union { union {
struct {
__be32 bb_leftsib;
__be32 bb_rightsib;
} s; /* short form pointers */
struct { struct {
xfs_agblock_t bb_leftsib; __be64 bb_leftsib;
xfs_agblock_t bb_rightsib; __be64 bb_rightsib;
} s; /* short form pointers */ } l; /* long form pointers */
struct { } bb_u; /* rest */
xfs_dfsbno_t bb_leftsib;
xfs_dfsbno_t bb_rightsib;
} l; /* long form pointers */
} bb_u; /* rest */
} xfs_btree_block_t; } xfs_btree_block_t;
/* /*
@ -113,12 +96,7 @@ typedef struct xfs_btree_block
/* /*
* Boolean to select which form of xfs_btree_block_t.bb_u to use. * Boolean to select which form of xfs_btree_block_t.bb_u to use.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BTREE_LONG_PTRS)
int xfs_btree_long_ptrs(xfs_btnum_t btnum);
#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) #define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
#else
#define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP)
#endif
/* /*
* Magic numbers for btree blocks. * Magic numbers for btree blocks.
@ -165,7 +143,7 @@ typedef struct xfs_btree_cur
struct xfs_trans *bc_tp; /* transaction we're in, if any */ struct xfs_trans *bc_tp; /* transaction we're in, if any */
struct xfs_mount *bc_mp; /* file system mount struct */ struct xfs_mount *bc_mp; /* file system mount struct */
union { union {
xfs_alloc_rec_t a; xfs_alloc_rec_incore_t a;
xfs_bmbt_irec_t b; xfs_bmbt_irec_t b;
xfs_inobt_rec_t i; xfs_inobt_rec_t i;
} bc_rec; /* current insert/search record value */ } bc_rec; /* current insert/search record value */
@ -205,24 +183,10 @@ typedef struct xfs_btree_cur
/* /*
* Convert from buffer to btree block header. * Convert from buffer to btree block header.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BLOCK) #define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp))
xfs_btree_block_t *xfs_buf_to_block(struct xfs_buf *bp); #define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp))
#define XFS_BUF_TO_BLOCK(bp) xfs_buf_to_block(bp) #define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
#else
#define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)(XFS_BUF_PTR(bp)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_LBLOCK)
xfs_btree_lblock_t *xfs_buf_to_lblock(struct xfs_buf *bp);
#define XFS_BUF_TO_LBLOCK(bp) xfs_buf_to_lblock(bp)
#else
#define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)(XFS_BUF_PTR(bp)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBLOCK)
xfs_btree_sblock_t *xfs_buf_to_sblock(struct xfs_buf *bp);
#define XFS_BUF_TO_SBLOCK(bp) xfs_buf_to_sblock(bp)
#else
#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)(XFS_BUF_PTR(bp)))
#endif
#ifdef __KERNEL__ #ifdef __KERNEL__
@ -477,106 +441,33 @@ xfs_btree_setbuf(
/* /*
* Min and max functions for extlen, agblock, fileoff, and filblks types. * Min and max functions for extlen, agblock, fileoff, and filblks types.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MIN)
xfs_extlen_t xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b);
#define XFS_EXTLEN_MIN(a,b) xfs_extlen_min(a,b)
#else
#define XFS_EXTLEN_MIN(a,b) \ #define XFS_EXTLEN_MIN(a,b) \
((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \
(xfs_extlen_t)(a) : (xfs_extlen_t)(b)) (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MAX)
xfs_extlen_t xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b);
#define XFS_EXTLEN_MAX(a,b) xfs_extlen_max(a,b)
#else
#define XFS_EXTLEN_MAX(a,b) \ #define XFS_EXTLEN_MAX(a,b) \
((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \
(xfs_extlen_t)(a) : (xfs_extlen_t)(b)) (xfs_extlen_t)(a) : (xfs_extlen_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MIN)
xfs_agblock_t xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b);
#define XFS_AGBLOCK_MIN(a,b) xfs_agblock_min(a,b)
#else
#define XFS_AGBLOCK_MIN(a,b) \ #define XFS_AGBLOCK_MIN(a,b) \
((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \
(xfs_agblock_t)(a) : (xfs_agblock_t)(b)) (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MAX)
xfs_agblock_t xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b);
#define XFS_AGBLOCK_MAX(a,b) xfs_agblock_max(a,b)
#else
#define XFS_AGBLOCK_MAX(a,b) \ #define XFS_AGBLOCK_MAX(a,b) \
((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \
(xfs_agblock_t)(a) : (xfs_agblock_t)(b)) (xfs_agblock_t)(a) : (xfs_agblock_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MIN)
xfs_fileoff_t xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b);
#define XFS_FILEOFF_MIN(a,b) xfs_fileoff_min(a,b)
#else
#define XFS_FILEOFF_MIN(a,b) \ #define XFS_FILEOFF_MIN(a,b) \
((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \
(xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MAX)
xfs_fileoff_t xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b);
#define XFS_FILEOFF_MAX(a,b) xfs_fileoff_max(a,b)
#else
#define XFS_FILEOFF_MAX(a,b) \ #define XFS_FILEOFF_MAX(a,b) \
((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \
(xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MIN)
xfs_filblks_t xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b);
#define XFS_FILBLKS_MIN(a,b) xfs_filblks_min(a,b)
#else
#define XFS_FILBLKS_MIN(a,b) \ #define XFS_FILBLKS_MIN(a,b) \
((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \
(xfs_filblks_t)(a) : (xfs_filblks_t)(b)) (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MAX)
xfs_filblks_t xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b);
#define XFS_FILBLKS_MAX(a,b) xfs_filblks_max(a,b)
#else
#define XFS_FILBLKS_MAX(a,b) \ #define XFS_FILBLKS_MAX(a,b) \
((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \
(xfs_filblks_t)(a) : (xfs_filblks_t)(b)) (xfs_filblks_t)(a) : (xfs_filblks_t)(b))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_SANITY_CHECK)
int xfs_fsb_sanity_check(struct xfs_mount *mp, xfs_fsblock_t fsb);
#define XFS_FSB_SANITY_CHECK(mp,fsb) xfs_fsb_sanity_check(mp,fsb)
#else
#define XFS_FSB_SANITY_CHECK(mp,fsb) \ #define XFS_FSB_SANITY_CHECK(mp,fsb) \
(XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \ (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \
XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks) XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks)
#endif
/*
* Macros to set EFSCORRUPTED & return/branch.
*/
#define XFS_WANT_CORRUPTED_GOTO(x,l) \
{ \
int fs_is_ok = (x); \
ASSERT(fs_is_ok); \
if (unlikely(!fs_is_ok)) { \
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
XFS_ERRLEVEL_LOW, NULL); \
error = XFS_ERROR(EFSCORRUPTED); \
goto l; \
} \
}
#define XFS_WANT_CORRUPTED_RETURN(x) \
{ \
int fs_is_ok = (x); \
ASSERT(fs_is_ok); \
if (unlikely(!fs_is_ok)) { \
XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
XFS_ERRLEVEL_LOW, NULL); \
return XFS_ERROR(EFSCORRUPTED); \
} \
}
#endif /* __XFS_BTREE_H__ */ #endif /* __XFS_BTREE_H__ */

View file

@ -1,57 +1,33 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
/*
* This file contains the implementation of the xfs_buf_log_item.
* It contains the item operations used to manipulate the buf log
* items as well as utility routines used by the buffer specific
* transaction routines.
*/
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_buf_item.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_buf_item.h"
#include "xfs_trans_priv.h" #include "xfs_trans_priv.h"
#include "xfs_rw.h"
#include "xfs_bit.h"
#include "xfs_error.h" #include "xfs_error.h"

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_BUF_ITEM_H__ #ifndef __XFS_BUF_ITEM_H__
#define __XFS_BUF_ITEM_H__ #define __XFS_BUF_ITEM_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_CAP_H__ #ifndef __XFS_CAP_H__
#define __XFS_CAP_H__ #define __XFS_CAP_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_CLNT_H__ #ifndef __XFS_CLNT_H__
#define __XFS_CLNT_H__ #define __XFS_CLNT_H__
@ -55,6 +41,7 @@
*/ */
struct xfs_mount_args { struct xfs_mount_args {
int flags; /* flags -> see XFSMNT_... macros below */ int flags; /* flags -> see XFSMNT_... macros below */
int flags2; /* flags -> see XFSMNT2_... macros below */
int logbufs; /* Number of log buffers, -1 to default */ int logbufs; /* Number of log buffers, -1 to default */
int logbufsize; /* Size of log buffers, -1 to default */ int logbufsize; /* Size of log buffers, -1 to default */
char fsname[MAXNAMELEN+1]; /* data device name */ char fsname[MAXNAMELEN+1]; /* data device name */
@ -68,9 +55,9 @@ struct xfs_mount_args {
}; };
/* /*
* XFS mount option flags * XFS mount option flags -- args->flags1
*/ */
#define XFSMNT_CHKLOG 0x00000001 /* check log */ #define XFSMNT_COMPAT_ATTR 0x00000001 /* do not use ATTR2 format */
#define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount #define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount
* compatible */ * compatible */
#define XFSMNT_INO64 0x00000004 /* move inode numbers up #define XFSMNT_INO64 0x00000004 /* move inode numbers up
@ -91,7 +78,7 @@ struct xfs_mount_args {
#define XFSMNT_SHARED 0x00001000 /* shared XFS mount */ #define XFSMNT_SHARED 0x00001000 /* shared XFS mount */
#define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */ #define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */
#define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */ #define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */
/* (osyncisdsync is now default) */ /* (osyncisdsync is default) */
#define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32 #define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32
* bits of address space */ * bits of address space */
#define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */ #define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */
@ -99,12 +86,19 @@ struct xfs_mount_args {
* enforcement */ * enforcement */
#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ #define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */
#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ #define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */
#define XFSMNT_NOLOGFLUSH 0x04000000 /* Don't flush for log blocks */ #define XFSMNT_BARRIER 0x04000000 /* use write barriers */
#define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ #define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */
#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width #define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width
* allocation */ * allocation */
#define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */ #define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */
#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename #define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename
* symlink,mkdir,rmdir,mknod */ * symlink,mkdir,rmdir,mknod */
#define XFSMNT_FLAGS2 0x80000000 /* more flags set in flags2 */
/*
* XFS mount option flags -- args->flags2
*/
#define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
* I/O size in stat(2) */
#endif /* __XFS_CLNT_H__ */ #endif /* __XFS_CLNT_H__ */

View file

@ -1,41 +1,26 @@
/* /*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h"
#include "xfs_macros.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
@ -43,19 +28,19 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_alloc_btree.h" #include "xfs_da_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h" #include "xfs_attr.h"
#include "xfs_attr_leaf.h" #include "xfs_attr_leaf.h"
#include "xfs_dir_leaf.h" #include "xfs_dir_leaf.h"
@ -64,7 +49,6 @@
#include "xfs_dir2_block.h" #include "xfs_dir2_block.h"
#include "xfs_dir2_node.h" #include "xfs_dir2_node.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_bit.h"
/* /*
* xfs_da_btree.c * xfs_da_btree.c
@ -190,9 +174,6 @@ xfs_da_split(xfs_da_state_t *state)
*/ */
switch (oldblk->magic) { switch (oldblk->magic) {
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
#ifndef __KERNEL__
return(ENOTTY);
#else
error = xfs_attr_leaf_split(state, oldblk, newblk); error = xfs_attr_leaf_split(state, oldblk, newblk);
if ((error != 0) && (error != ENOSPC)) { if ((error != 0) && (error != ENOSPC)) {
return(error); /* GROT: attr is inconsistent */ return(error); /* GROT: attr is inconsistent */
@ -218,7 +199,6 @@ xfs_da_split(xfs_da_state_t *state)
return(error); /* GROT: attr inconsistent */ return(error); /* GROT: attr inconsistent */
addblk = newblk; addblk = newblk;
break; break;
#endif
case XFS_DIR_LEAF_MAGIC: case XFS_DIR_LEAF_MAGIC:
ASSERT(XFS_DIR_IS_V1(state->mp)); ASSERT(XFS_DIR_IS_V1(state->mp));
error = xfs_dir_leaf_split(state, oldblk, newblk); error = xfs_dir_leaf_split(state, oldblk, newblk);
@ -449,7 +429,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
/* /*
* With V2 the extra block is data or freespace. * With V2 the extra block is data or freespace.
*/ */
useextra = state->extravalid && XFS_DIR_IS_V1(state->mp); useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) ||
state->args->whichfork == XFS_ATTR_FORK);
newcount = 1 + useextra; newcount = 1 + useextra;
/* /*
* Do we have to split the node? * Do we have to split the node?
@ -706,18 +687,12 @@ xfs_da_join(xfs_da_state_t *state)
*/ */
switch (drop_blk->magic) { switch (drop_blk->magic) {
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
#ifndef __KERNEL__
error = ENOTTY;
#else
error = xfs_attr_leaf_toosmall(state, &action); error = xfs_attr_leaf_toosmall(state, &action);
#endif
if (error) if (error)
return(error); return(error);
if (action == 0) if (action == 0)
return(0); return(0);
#ifdef __KERNEL__
xfs_attr_leaf_unbalance(state, drop_blk, save_blk); xfs_attr_leaf_unbalance(state, drop_blk, save_blk);
#endif
break; break;
case XFS_DIR_LEAF_MAGIC: case XFS_DIR_LEAF_MAGIC:
ASSERT(XFS_DIR_IS_V1(state->mp)); ASSERT(XFS_DIR_IS_V1(state->mp));
@ -973,13 +948,11 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
level = path->active-1; level = path->active-1;
blk = &path->blk[ level ]; blk = &path->blk[ level ];
switch (blk->magic) { switch (blk->magic) {
#ifdef __KERNEL__
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); lasthash = xfs_attr_leaf_lasthash(blk->bp, &count);
if (count == 0) if (count == 0)
return; return;
break; break;
#endif
case XFS_DIR_LEAF_MAGIC: case XFS_DIR_LEAF_MAGIC:
ASSERT(XFS_DIR_IS_V1(state->mp)); ASSERT(XFS_DIR_IS_V1(state->mp));
lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); lasthash = xfs_dir_leaf_lasthash(blk->bp, &count);
@ -1220,12 +1193,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
blkno = INT_GET(btree->before, ARCH_CONVERT); blkno = INT_GET(btree->before, ARCH_CONVERT);
} }
} }
#ifdef __KERNEL__
else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
break; break;
} }
#endif
else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) {
blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
break; break;
@ -1252,13 +1223,11 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
retval = xfs_dir2_leafn_lookup_int(blk->bp, args, retval = xfs_dir2_leafn_lookup_int(blk->bp, args,
&blk->index, state); &blk->index, state);
} }
#ifdef __KERNEL__
else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
retval = xfs_attr_leaf_lookup_int(blk->bp, args); retval = xfs_attr_leaf_lookup_int(blk->bp, args);
blk->index = args->index; blk->index = args->index;
args->blkno = blk->blkno; args->blkno = blk->blkno;
} }
#endif
if (((retval == ENOENT) || (retval == ENOATTR)) && if (((retval == ENOENT) || (retval == ENOATTR)) &&
(blk->hashval == args->hashval)) { (blk->hashval == args->hashval)) {
error = xfs_da_path_shift(state, &state->path, 1, 1, error = xfs_da_path_shift(state, &state->path, 1, 1,
@ -1268,12 +1237,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
if (retval == 0) { if (retval == 0) {
continue; continue;
} }
#ifdef __KERNEL__
else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
/* path_shift() gives ENOENT */ /* path_shift() gives ENOENT */
retval = XFS_ERROR(ENOATTR); retval = XFS_ERROR(ENOATTR);
} }
#endif
} }
break; break;
} }
@ -1312,11 +1279,9 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
ASSERT(old_blk->magic == new_blk->magic); ASSERT(old_blk->magic == new_blk->magic);
switch (old_blk->magic) { switch (old_blk->magic) {
#ifdef __KERNEL__
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp);
break; break;
#endif
case XFS_DIR_LEAF_MAGIC: case XFS_DIR_LEAF_MAGIC:
ASSERT(XFS_DIR_IS_V1(state->mp)); ASSERT(XFS_DIR_IS_V1(state->mp));
before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp);
@ -1587,12 +1552,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
ASSERT(level == path->active-1); ASSERT(level == path->active-1);
blk->index = 0; blk->index = 0;
switch(blk->magic) { switch(blk->magic) {
#ifdef __KERNEL__
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, blk->hashval = xfs_attr_leaf_lasthash(blk->bp,
NULL); NULL);
break; break;
#endif
case XFS_DIR_LEAF_MAGIC: case XFS_DIR_LEAF_MAGIC:
ASSERT(XFS_DIR_IS_V1(state->mp)); ASSERT(XFS_DIR_IS_V1(state->mp));
blk->hashval = xfs_dir_leaf_lasthash(blk->bp, blk->hashval = xfs_dir_leaf_lasthash(blk->bp,
@ -1626,19 +1589,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
* This is implemented with some source-level loop unrolling. * This is implemented with some source-level loop unrolling.
*/ */
xfs_dahash_t xfs_dahash_t
xfs_da_hashname(uchar_t *name, int namelen) xfs_da_hashname(const uchar_t *name, int namelen)
{ {
xfs_dahash_t hash; xfs_dahash_t hash;
#ifdef SLOWVERSION
/*
* This is the old one-byte-at-a-time version.
*/
for (hash = 0; namelen > 0; namelen--)
hash = *name++ ^ rol32(hash, 7);
return(hash);
#else
/* /*
* Do four characters at a time as long as we can. * Do four characters at a time as long as we can.
*/ */
@ -1657,12 +1611,9 @@ xfs_da_hashname(uchar_t *name, int namelen)
return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2);
case 1: case 1:
return (name[0] << 0) ^ rol32(hash, 7 * 1); return (name[0] << 0) ^ rol32(hash, 7 * 1);
case 0: default: /* case 0: */
return hash; return hash;
} }
/* NOTREACHED */
#endif
return 0; /* keep gcc happy */
} }
/* /*
@ -2200,20 +2151,16 @@ xfs_da_do_buf(
error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO);
break; break;
case 1: case 1:
#ifndef __KERNEL__
case 2: case 2:
#endif
bp = NULL; bp = NULL;
error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp,
mappedbno, nmapped, 0, &bp); mappedbno, nmapped, 0, &bp);
break; break;
#ifdef __KERNEL__
case 3: case 3:
xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); xfs_baread(mp->m_ddev_targp, mappedbno, nmapped);
error = 0; error = 0;
bp = NULL; bp = NULL;
break; break;
#endif
} }
if (error) { if (error) {
if (bp) if (bp)

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_DA_BTREE_H__ #ifndef __XFS_DA_BTREE_H__
#define __XFS_DA_BTREE_H__ #define __XFS_DA_BTREE_H__
@ -92,72 +78,24 @@ typedef struct xfs_da_node_entry xfs_da_node_entry_t;
#define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */ #define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */
/* #define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize
* Macros used by directory code to interface to the filesystem. #define XFS_LBLOG(mp) (mp)->m_sb.sb_blocklog
*/
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBSIZE)
int xfs_lbsize(struct xfs_mount *mp);
#define XFS_LBSIZE(mp) xfs_lbsize(mp)
#else
#define XFS_LBSIZE(mp) ((mp)->m_sb.sb_blocksize)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBLOG)
int xfs_lblog(struct xfs_mount *mp);
#define XFS_LBLOG(mp) xfs_lblog(mp)
#else
#define XFS_LBLOG(mp) ((mp)->m_sb.sb_blocklog)
#endif
/*
* Macros used by directory code to interface to the kernel
*/
/*
* Macros used to manipulate directory off_t's
*/
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_BNOENTRY)
__uint32_t xfs_da_make_bnoentry(struct xfs_mount *mp, xfs_dablk_t bno,
int entry);
#define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \ #define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \
xfs_da_make_bnoentry(mp,bno,entry)
#else
#define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \
(((bno) << (mp)->m_dircook_elog) | (entry)) (((bno) << (mp)->m_dircook_elog) | (entry))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_COOKIE)
xfs_off_t xfs_da_make_cookie(struct xfs_mount *mp, xfs_dablk_t bno, int entry,
xfs_dahash_t hash);
#define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \ #define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \
xfs_da_make_cookie(mp,bno,entry,hash)
#else
#define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \
(((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash)) (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash))
#endif #define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)cookie)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_HASH) #define XFS_DA_COOKIE_BNO(mp,cookie) \
xfs_dahash_t xfs_da_cookie_hash(struct xfs_mount *mp, xfs_off_t cookie); ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
#define XFS_DA_COOKIE_HASH(mp,cookie) xfs_da_cookie_hash(mp,cookie)
#else
#define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)(cookie))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_BNO)
xfs_dablk_t xfs_da_cookie_bno(struct xfs_mount *mp, xfs_off_t cookie);
#define XFS_DA_COOKIE_BNO(mp,cookie) xfs_da_cookie_bno(mp,cookie)
#else
#define XFS_DA_COOKIE_BNO(mp,cookie) \
(((xfs_off_t)(cookie) >> 31) == -1LL ? \
(xfs_dablk_t)0 : \ (xfs_dablk_t)0 : \
(xfs_dablk_t)((xfs_off_t)(cookie) >> ((mp)->m_dircook_elog + 32))) (xfs_dablk_t)((xfs_off_t)(cookie) >> \
#endif ((mp)->m_dircook_elog + 32))))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_ENTRY) #define XFS_DA_COOKIE_ENTRY(mp,cookie) \
int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie); ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
#define XFS_DA_COOKIE_ENTRY(mp,cookie) xfs_da_cookie_entry(mp,cookie)
#else
#define XFS_DA_COOKIE_ENTRY(mp,cookie) \
(((xfs_off_t)(cookie) >> 31) == -1LL ? \
(xfs_dablk_t)0 : \ (xfs_dablk_t)0 : \
(xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \ (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \
((1 << (mp)->m_dircook_elog) - 1))) ((1 << (mp)->m_dircook_elog) - 1))))
#endif
/*======================================================================== /*========================================================================
@ -168,7 +106,7 @@ int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie);
* Structure to ease passing around component names. * Structure to ease passing around component names.
*/ */
typedef struct xfs_da_args { typedef struct xfs_da_args {
uchar_t *name; /* string (maybe not NULL terminated) */ const uchar_t *name; /* string (maybe not NULL terminated) */
int namelen; /* length of string (maybe no NULL) */ int namelen; /* length of string (maybe no NULL) */
uchar_t *value; /* set of bytes (maybe contain NULLs) */ uchar_t *value; /* set of bytes (maybe contain NULLs) */
int valuelen; /* length of value */ int valuelen; /* length of value */
@ -314,7 +252,7 @@ xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
xfs_dabuf_t *dead_buf); xfs_dabuf_t *dead_buf);
uint xfs_da_hashname(uchar_t *name_string, int name_length); uint xfs_da_hashname(const uchar_t *name_string, int name_length);
uint xfs_da_log2_roundup(uint i); uint xfs_da_log2_roundup(uint i);
xfs_da_state_t *xfs_da_state_alloc(void); xfs_da_state_t *xfs_da_state_alloc(void);
void xfs_da_state_free(xfs_da_state_t *state); void xfs_da_state_free(xfs_da_state_t *state);

View file

@ -1,58 +1,44 @@
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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/
*/ */
#include "xfs.h" #include "xfs.h"
#include "xfs_macros.h" #include "xfs_fs.h"
#include "xfs_types.h" #include "xfs_types.h"
#include "xfs_inum.h" #include "xfs_bit.h"
#include "xfs_log.h" #include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir.h" #include "xfs_dir.h"
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_ag.h"
#include "xfs_alloc_btree.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_alloc_btree.h"
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir_sf.h" #include "xfs_dir_sf.h"
#include "xfs_dir2_sf.h" #include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode_item.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_btree.h"
#include "xfs_ialloc.h" #include "xfs_ialloc.h"
#include "xfs_itable.h" #include "xfs_itable.h"
#include "xfs_dfrag.h" #include "xfs_dfrag.h"
@ -65,9 +51,9 @@
*/ */
int int
xfs_swapext( xfs_swapext(
xfs_swapext_t __user *sxp) xfs_swapext_t __user *sxu)
{ {
xfs_swapext_t sx; xfs_swapext_t *sxp;
xfs_inode_t *ip=NULL, *tip=NULL, *ips[2]; xfs_inode_t *ip=NULL, *tip=NULL, *ips[2];
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_mount_t *mp; xfs_mount_t *mp;
@ -76,20 +62,29 @@ xfs_swapext(
vnode_t *vp, *tvp; vnode_t *vp, *tvp;
bhv_desc_t *bdp, *tbdp; bhv_desc_t *bdp, *tbdp;
vn_bhv_head_t *bhp, *tbhp; vn_bhv_head_t *bhp, *tbhp;
uint lock_flags=0; static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
int ilf_fields, tilf_fields; int ilf_fields, tilf_fields;
int error = 0; int error = 0;
xfs_ifork_t tempif, *ifp, *tifp; xfs_ifork_t *tempifp, *ifp, *tifp;
__uint64_t tmp; __uint64_t tmp;
int aforkblks = 0; int aforkblks = 0;
int taforkblks = 0; int taforkblks = 0;
int locked = 0; char locked = 0;
if (copy_from_user(&sx, sxp, sizeof(sx))) sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL);
return XFS_ERROR(EFAULT); tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL);
if (!sxp || !tempifp) {
error = XFS_ERROR(ENOMEM);
goto error0;
}
if (copy_from_user(sxp, sxu, sizeof(xfs_swapext_t))) {
error = XFS_ERROR(EFAULT);
goto error0;
}
/* Pull information for the target fd */ /* Pull information for the target fd */
if (((fp = fget((int)sx.sx_fdtarget)) == NULL) || if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) ||
((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) {
error = XFS_ERROR(EINVAL); error = XFS_ERROR(EINVAL);
goto error0; goto error0;
@ -104,7 +99,7 @@ xfs_swapext(
ip = XFS_BHVTOI(bdp); ip = XFS_BHVTOI(bdp);
} }
if (((tfp = fget((int)sx.sx_fdtmp)) == NULL) || if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) ||
((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) {
error = XFS_ERROR(EINVAL); error = XFS_ERROR(EINVAL);
goto error0; goto error0;
@ -131,7 +126,7 @@ xfs_swapext(
mp = ip->i_mount; mp = ip->i_mount;
sbp = &sx.sx_stat; sbp = &sxp->sx_stat;
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
error = XFS_ERROR(EIO); error = XFS_ERROR(EIO);
@ -148,7 +143,7 @@ xfs_swapext(
ips[0] = tip; ips[0] = tip;
ips[1] = ip; ips[1] = ip;
} }
lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
xfs_lock_inodes(ips, 2, 0, lock_flags); xfs_lock_inodes(ips, 2, 0, lock_flags);
/* Check permissions */ /* Check permissions */
@ -192,9 +187,9 @@ xfs_swapext(
} }
/* Verify all data are being swapped */ /* Verify all data are being swapped */
if (sx.sx_offset != 0 || if (sxp->sx_offset != 0 ||
sx.sx_length != ip->i_d.di_size || sxp->sx_length != ip->i_d.di_size ||
sx.sx_length != tip->i_d.di_size) { sxp->sx_length != tip->i_d.di_size) {
error = XFS_ERROR(EFAULT); error = XFS_ERROR(EFAULT);
goto error0; goto error0;
} }
@ -255,7 +250,8 @@ xfs_swapext(
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
xfs_iunlock(tip, XFS_IOLOCK_EXCL); xfs_iunlock(tip, XFS_IOLOCK_EXCL);
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return error; locked = 0;
goto error0;
} }
xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL); xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL);
@ -266,10 +262,8 @@ xfs_swapext(
(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) {
error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks); error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks);
if (error) { if (error) {
xfs_iunlock(ip, lock_flags);
xfs_iunlock(tip, lock_flags);
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return error; goto error0;
} }
} }
if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) && if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) &&
@ -277,10 +271,8 @@ xfs_swapext(
error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK,
&taforkblks); &taforkblks);
if (error) { if (error) {
xfs_iunlock(ip, lock_flags);
xfs_iunlock(tip, lock_flags);
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
return error; goto error0;
} }
} }
@ -289,9 +281,9 @@ xfs_swapext(
*/ */
ifp = &ip->i_df; ifp = &ip->i_df;
tifp = &tip->i_df; tifp = &tip->i_df;
tempif = *ifp; /* struct copy */ *tempifp = *ifp; /* struct copy */
*ifp = *tifp; /* struct copy */ *ifp = *tifp; /* struct copy */
*tifp = tempif; /* struct copy */ *tifp = *tempifp; /* struct copy */
/* /*
* Fix the on-disk inode values * Fix the on-disk inode values
@ -369,11 +361,7 @@ xfs_swapext(
} }
error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL); error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL);
locked = 0;
fput(fp);
fput(tfp);
return error;
error0: error0:
if (locked) { if (locked) {
@ -381,8 +369,15 @@ xfs_swapext(
xfs_iunlock(tip, lock_flags); xfs_iunlock(tip, lock_flags);
} }
if (fp != NULL) fput(fp); if (fp != NULL)
if (tfp != NULL) fput(tfp); fput(fp);
if (tfp != NULL)
fput(tfp);
if (sxp != NULL)
kmem_free(sxp, sizeof(xfs_swapext_t));
if (tempifp != NULL)
kmem_free(tempifp, sizeof(xfs_ifork_t));
return error; return error;
} }

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_DFRAG_H__ #ifndef __XFS_DFRAG_H__
#define __XFS_DFRAG_H__ #define __XFS_DFRAG_H__

View file

@ -1,33 +1,19 @@
/* /*
* Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or
* under the terms of version 2 of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This program is distributed in the hope that it would be useful, but * This program is distributed in the hope that it would be useful,
* WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* Further, this software is distributed without any warranty that it is * You should have received a copy of the GNU General Public License
* free of the rightful claim of any third person regarding infringement * along with this program; if not, write the Free Software Foundation,
* or the like. Any license provided herein, whether implied or * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* 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_DINODE_H__ #ifndef __XFS_DINODE_H__
#define __XFS_DINODE_H__ #define __XFS_DINODE_H__
@ -37,13 +23,8 @@ struct xfs_mount;
#define XFS_DINODE_VERSION_1 1 #define XFS_DINODE_VERSION_1 1
#define XFS_DINODE_VERSION_2 2 #define XFS_DINODE_VERSION_2 2
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DINODE_GOOD_VERSION) #define XFS_DINODE_GOOD_VERSION(v) \
int xfs_dinode_good_version(int v); (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2))
#define XFS_DINODE_GOOD_VERSION(v) xfs_dinode_good_version(v)
#else
#define XFS_DINODE_GOOD_VERSION(v) (((v) == XFS_DINODE_VERSION_1) || \
((v) == XFS_DINODE_VERSION_2))
#endif
#define XFS_DINODE_MAGIC 0x494e /* 'IN' */ #define XFS_DINODE_MAGIC 0x494e /* 'IN' */
/* /*
@ -184,75 +165,30 @@ typedef enum xfs_dinode_fmt
/* /*
* Inode size for given fs. * Inode size for given fs.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LITINO)
int xfs_litino(struct xfs_mount *mp);
#define XFS_LITINO(mp) xfs_litino(mp)
#else
#define XFS_LITINO(mp) ((mp)->m_litino) #define XFS_LITINO(mp) ((mp)->m_litino)
#endif
#define XFS_BROOT_SIZE_ADJ \ #define XFS_BROOT_SIZE_ADJ \
(sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t))
/*
* Fork identifiers. Here so utilities can use them without including
* xfs_inode.h.
*/
#define XFS_DATA_FORK 0
#define XFS_ATTR_FORK 1
/* /*
* Inode data & attribute fork sizes, per inode. * Inode data & attribute fork sizes, per inode.
*/ */
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_Q)
int xfs_cfork_q_disk(xfs_dinode_core_t *dcp);
int xfs_cfork_q(xfs_dinode_core_t *dcp);
#define XFS_CFORK_Q_DISK(dcp) xfs_cfork_q_disk(dcp)
#define XFS_CFORK_Q(dcp) xfs_cfork_q(dcp)
#else
#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
#define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) #define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0)
#define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_BOFF)
int xfs_cfork_boff_disk(xfs_dinode_core_t *dcp);
int xfs_cfork_boff(xfs_dinode_core_t *dcp);
#define XFS_CFORK_BOFF_DISK(dcp) xfs_cfork_boff_disk(dcp)
#define XFS_CFORK_BOFF(dcp) xfs_cfork_boff(dcp)
#else
#define XFS_CFORK_BOFF_DISK(dcp) ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
#define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3))
#define XFS_CFORK_BOFF_DISK(dcp) \
((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_DSIZE)
int xfs_cfork_dsize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
int xfs_cfork_dsize(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
#define XFS_CFORK_DSIZE_DISK(dcp,mp) xfs_cfork_dsize_disk(dcp,mp)
#define XFS_CFORK_DSIZE(dcp,mp) xfs_cfork_dsize(dcp,mp)
#else
#define XFS_CFORK_DSIZE_DISK(dcp,mp) \ #define XFS_CFORK_DSIZE_DISK(dcp,mp) \
(XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp))
#define XFS_CFORK_DSIZE(dcp,mp) \ #define XFS_CFORK_DSIZE(dcp,mp) \
(XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp)) (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_ASIZE)
int xfs_cfork_asize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
int xfs_cfork_asize(xfs_dinode_core_t *dcp, struct xfs_mount *mp);
#define XFS_CFORK_ASIZE_DISK(dcp,mp) xfs_cfork_asize_disk(dcp,mp)
#define XFS_CFORK_ASIZE(dcp,mp) xfs_cfork_asize(dcp,mp)
#else
#define XFS_CFORK_ASIZE_DISK(dcp,mp) \ #define XFS_CFORK_ASIZE_DISK(dcp,mp) \
(XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0) (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0)
#define XFS_CFORK_ASIZE(dcp,mp) \ #define XFS_CFORK_ASIZE(dcp,mp) \
(XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0) (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_SIZE)
int xfs_cfork_size_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
#define XFS_CFORK_SIZE_DISK(dcp,mp,w) xfs_cfork_size_disk(dcp,mp,w)
#define XFS_CFORK_SIZE(dcp,mp,w) xfs_cfork_size(dcp,mp,w)
#else
#define XFS_CFORK_SIZE_DISK(dcp,mp,w) \ #define XFS_CFORK_SIZE_DISK(dcp,mp,w) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
XFS_CFORK_DSIZE_DISK(dcp, mp) : \ XFS_CFORK_DSIZE_DISK(dcp, mp) : \
@ -261,93 +197,26 @@ int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w);
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp)) XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp))
#endif #define XFS_DFORK_DSIZE(dip,mp) \
XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp)
#define XFS_DFORK_ASIZE(dip,mp) \
XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp)
#define XFS_DFORK_SIZE(dip,mp,w) \
XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w)
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DSIZE)
int xfs_dfork_dsize(xfs_dinode_t *dip, struct xfs_mount *mp);
#define XFS_DFORK_DSIZE(dip,mp) xfs_dfork_dsize(dip,mp)
#else
#define XFS_DFORK_DSIZE(dip,mp) XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_ASIZE)
int xfs_dfork_asize(xfs_dinode_t *dip, struct xfs_mount *mp);
#define XFS_DFORK_ASIZE(dip,mp) xfs_dfork_asize(dip,mp)
#else
#define XFS_DFORK_ASIZE(dip,mp) XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_SIZE)
int xfs_dfork_size(xfs_dinode_t *dip, struct xfs_mount *mp, int w);
#define XFS_DFORK_SIZE(dip,mp,w) xfs_dfork_size(dip,mp,w)
#else
#define XFS_DFORK_SIZE(dip,mp,w) XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w)
#endif
/*
* Macros for accessing per-fork disk inode information.
*/
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_Q)
int xfs_dfork_q(xfs_dinode_t *dip);
#define XFS_DFORK_Q(dip) xfs_dfork_q(dip)
#else
#define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core) #define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_BOFF)
int xfs_dfork_boff(xfs_dinode_t *dip);
#define XFS_DFORK_BOFF(dip) xfs_dfork_boff(dip)
#else
#define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core) #define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DPTR)
char *xfs_dfork_dptr(xfs_dinode_t *dip);
#define XFS_DFORK_DPTR(dip) xfs_dfork_dptr(dip)
#else
#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c)
#define XFS_DFORK_APTR(dip) \
#endif ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_APTR)
char *xfs_dfork_aptr(xfs_dinode_t *dip);
#define XFS_DFORK_APTR(dip) xfs_dfork_aptr(dip)
#else
#define XFS_DFORK_APTR(dip) ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_PTR)
char *xfs_dfork_ptr(xfs_dinode_t *dip, int w);
#define XFS_DFORK_PTR(dip,w) xfs_dfork_ptr(dip,w)
#else
#define XFS_DFORK_PTR(dip,w) \ #define XFS_DFORK_PTR(dip,w) \
((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
#define XFS_CFORK_FORMAT(dcp,w) \
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FORMAT)
int xfs_cfork_format(xfs_dinode_core_t *dcp, int w);
#define XFS_CFORK_FORMAT(dcp,w) xfs_cfork_format(dcp,w)
#else
#define XFS_CFORK_FORMAT(dcp,w) \
((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat) ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FMT_SET)
void xfs_cfork_fmt_set(xfs_dinode_core_t *dcp, int w, int n);
#define XFS_CFORK_FMT_SET(dcp,w,n) xfs_cfork_fmt_set(dcp,w,n)
#else
#define XFS_CFORK_FMT_SET(dcp,w,n) \ #define XFS_CFORK_FMT_SET(dcp,w,n) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
((dcp)->di_format = (n)) : \ ((dcp)->di_format = (n)) : ((dcp)->di_aformat = (n)))
((dcp)->di_aformat = (n)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXTENTS)
int xfs_cfork_nextents_disk(xfs_dinode_core_t *dcp, int w);
int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w);
#define XFS_CFORK_NEXTENTS_DISK(dcp,w) xfs_cfork_nextents_disk(dcp,w)
#define XFS_CFORK_NEXTENTS(dcp,w) xfs_cfork_nextents(dcp,w)
#else
#define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \
@ -355,31 +224,13 @@ int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w);
#define XFS_CFORK_NEXTENTS(dcp,w) \ #define XFS_CFORK_NEXTENTS(dcp,w) \
((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXT_SET)
void xfs_cfork_next_set(xfs_dinode_core_t *dcp, int w, int n);
#define XFS_CFORK_NEXT_SET(dcp,w,n) xfs_cfork_next_set(dcp,w,n)
#else
#define XFS_CFORK_NEXT_SET(dcp,w,n) \ #define XFS_CFORK_NEXT_SET(dcp,w,n) \
((w) == XFS_DATA_FORK ? \ ((w) == XFS_DATA_FORK ? \
((dcp)->di_nextents = (n)) : \ ((dcp)->di_nextents = (n)) : ((dcp)->di_anextents = (n)))
((dcp)->di_anextents = (n)))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_NEXTENTS)
int xfs_dfork_nextents(xfs_dinode_t *dip, int w);
#define XFS_DFORK_NEXTENTS(dip,w) xfs_dfork_nextents(dip,w)
#else
#define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w)
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE) #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
#define XFS_BUF_TO_DINODE(bp) xfs_buf_to_dinode(bp)
#else
#define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)(XFS_BUF_PTR(bp)))
#endif
/* /*
* Values for di_flags * Values for di_flags

Some files were not shown because too many files have changed in this diff Show more