提交 2d896c78 编写于 作者: L Linus Torvalds

Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6

* 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6: (37 commits)
  [XFS] Fix lockdep annotations for xfs_lock_inodes
  [LIB]: export radix_tree_preload()
  [XFS] Fix XFS_IOC_FSBULKSTAT{,_SINGLE} & XFS_IOC_FSINUMBERS in compat mode
  [XFS] Compat ioctl handler for handle operations
  [XFS] Compat ioctl handler for XFS_IOC_FSGEOMETRY_V1.
  [XFS] Clean up function name handling in tracing code
  [XFS] Quota inode has no parent.
  [XFS] Concurrent Multi-File Data Streams
  [XFS] Use uninitialized_var macro to stop warning about rtx
  [XFS] XFS should not be looking at filp reference counts
  [XFS] Use is_power_of_2 instead of open coding checks
  [XFS] Reduce shouting by removing unnecessary macros from dir2 code.
  [XFS] Simplify XFS min/max macros.
  [XFS] Kill off xfs_count_bits
  [XFS] Cancel transactions on xfs_itruncate_start error.
  [XFS] Use do_div() on 64 bit types.
  [XFS] Fix remount,readonly path to flush everything correctly.
  [XFS] Cleanup inode extent size hint extraction
  [XFS] Prevent ENOSPC from aborting transactions that need to succeed
  [XFS] Prevent deadlock when flushing inodes on unmount
  ...
...@@ -64,6 +64,7 @@ xfs-y += xfs_alloc.o \ ...@@ -64,6 +64,7 @@ xfs-y += xfs_alloc.o \
xfs_dir2_sf.o \ xfs_dir2_sf.o \
xfs_error.o \ xfs_error.o \
xfs_extfree_item.o \ xfs_extfree_item.o \
xfs_filestream.o \
xfs_fsops.o \ xfs_fsops.o \
xfs_ialloc.o \ xfs_ialloc.o \
xfs_ialloc_btree.o \ xfs_ialloc_btree.o \
...@@ -77,6 +78,7 @@ xfs-y += xfs_alloc.o \ ...@@ -77,6 +78,7 @@ xfs-y += xfs_alloc.o \
xfs_log.o \ xfs_log.o \
xfs_log_recover.o \ xfs_log_recover.o \
xfs_mount.o \ xfs_mount.o \
xfs_mru_cache.o \
xfs_rename.o \ xfs_rename.o \
xfs_trans.o \ xfs_trans.o \
xfs_trans_ail.o \ xfs_trans_ail.o \
......
...@@ -100,25 +100,6 @@ kmem_zone_destroy(kmem_zone_t *zone) ...@@ -100,25 +100,6 @@ kmem_zone_destroy(kmem_zone_t *zone)
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_zone_zalloc(kmem_zone_t *, unsigned int __nocast); extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
/*
* Low memory cache shrinkers
*/
typedef struct shrinker *kmem_shaker_t;
typedef int (*kmem_shake_func_t)(int, gfp_t);
static inline kmem_shaker_t
kmem_shake_register(kmem_shake_func_t sfunc)
{
return set_shrinker(DEFAULT_SEEKS, sfunc);
}
static inline void
kmem_shake_deregister(kmem_shaker_t shrinker)
{
remove_shrinker(shrinker);
}
static inline int static inline int
kmem_shake_allow(gfp_t gfp_mask) kmem_shake_allow(gfp_t gfp_mask)
{ {
......
...@@ -108,14 +108,19 @@ xfs_page_trace( ...@@ -108,14 +108,19 @@ xfs_page_trace(
/* /*
* Schedule IO completion handling on a xfsdatad if this was * Schedule IO completion handling on a xfsdatad if this was
* the final hold on this ioend. * the final hold on this ioend. If we are asked to wait,
* flush the workqueue.
*/ */
STATIC void STATIC void
xfs_finish_ioend( xfs_finish_ioend(
xfs_ioend_t *ioend) xfs_ioend_t *ioend,
int wait)
{ {
if (atomic_dec_and_test(&ioend->io_remaining)) if (atomic_dec_and_test(&ioend->io_remaining)) {
queue_work(xfsdatad_workqueue, &ioend->io_work); queue_work(xfsdatad_workqueue, &ioend->io_work);
if (wait)
flush_workqueue(xfsdatad_workqueue);
}
} }
/* /*
...@@ -156,6 +161,8 @@ xfs_setfilesize( ...@@ -156,6 +161,8 @@ xfs_setfilesize(
xfs_fsize_t bsize; xfs_fsize_t bsize;
ip = xfs_vtoi(ioend->io_vnode); ip = xfs_vtoi(ioend->io_vnode);
if (!ip)
return;
ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
ASSERT(ioend->io_type != IOMAP_READ); ASSERT(ioend->io_type != IOMAP_READ);
...@@ -334,7 +341,7 @@ xfs_end_bio( ...@@ -334,7 +341,7 @@ xfs_end_bio(
bio->bi_end_io = NULL; bio->bi_end_io = NULL;
bio_put(bio); bio_put(bio);
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend, 0);
return 0; return 0;
} }
...@@ -470,7 +477,7 @@ xfs_submit_ioend( ...@@ -470,7 +477,7 @@ xfs_submit_ioend(
} }
if (bio) if (bio)
xfs_submit_ioend_bio(ioend, bio); xfs_submit_ioend_bio(ioend, bio);
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend, 0);
} while ((ioend = next) != NULL); } while ((ioend = next) != NULL);
} }
...@@ -1003,6 +1010,8 @@ xfs_page_state_convert( ...@@ -1003,6 +1010,8 @@ xfs_page_state_convert(
if (buffer_unwritten(bh) || buffer_delay(bh) || if (buffer_unwritten(bh) || buffer_delay(bh) ||
((buffer_uptodate(bh) || PageUptodate(page)) && ((buffer_uptodate(bh) || PageUptodate(page)) &&
!buffer_mapped(bh) && (unmapped || startio))) { !buffer_mapped(bh) && (unmapped || startio))) {
int new_ioend = 0;
/* /*
* Make sure we don't use a read-only iomap * Make sure we don't use a read-only iomap
*/ */
...@@ -1021,6 +1030,15 @@ xfs_page_state_convert( ...@@ -1021,6 +1030,15 @@ xfs_page_state_convert(
} }
if (!iomap_valid) { if (!iomap_valid) {
/*
* if we didn't have a valid mapping then we
* need to ensure that we put the new mapping
* in a new ioend structure. This needs to be
* done to ensure that the ioends correctly
* reflect the block mappings at io completion
* for unwritten extent conversion.
*/
new_ioend = 1;
if (type == IOMAP_NEW) { if (type == IOMAP_NEW) {
size = xfs_probe_cluster(inode, size = xfs_probe_cluster(inode,
page, bh, head, 0); page, bh, head, 0);
...@@ -1040,7 +1058,7 @@ xfs_page_state_convert( ...@@ -1040,7 +1058,7 @@ xfs_page_state_convert(
if (startio) { if (startio) {
xfs_add_to_ioend(inode, bh, offset, xfs_add_to_ioend(inode, bh, offset,
type, &ioend, type, &ioend,
!iomap_valid); new_ioend);
} else { } else {
set_buffer_dirty(bh); set_buffer_dirty(bh);
unlock_buffer(bh); unlock_buffer(bh);
...@@ -1416,6 +1434,13 @@ xfs_end_io_direct( ...@@ -1416,6 +1434,13 @@ xfs_end_io_direct(
* This is not necessary for synchronous direct I/O, but we do * This is not necessary for synchronous direct I/O, but we do
* it anyway to keep the code uniform and simpler. * it anyway to keep the code uniform and simpler.
* *
* Well, if only it were that simple. Because synchronous direct I/O
* requires extent conversion to occur *before* we return to userspace,
* we have to wait for extent conversion to complete. Look at the
* iocb that has been passed to us to determine if this is AIO or
* not. If it is synchronous, tell xfs_finish_ioend() to kick the
* workqueue and wait for it to complete.
*
* The core direct I/O code might be changed to always call the * The core direct I/O code might be changed to always call the
* completion handler in the future, in which case all this can * completion handler in the future, in which case all this can
* go away. * go away.
...@@ -1423,9 +1448,9 @@ xfs_end_io_direct( ...@@ -1423,9 +1448,9 @@ xfs_end_io_direct(
ioend->io_offset = offset; ioend->io_offset = offset;
ioend->io_size = size; ioend->io_size = size;
if (ioend->io_type == IOMAP_READ) { if (ioend->io_type == IOMAP_READ) {
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend, 0);
} else if (private && size > 0) { } else if (private && size > 0) {
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend, is_sync_kiocb(iocb));
} else { } else {
/* /*
* A direct I/O write ioend starts it's life in unwritten * A direct I/O write ioend starts it's life in unwritten
...@@ -1434,7 +1459,7 @@ xfs_end_io_direct( ...@@ -1434,7 +1459,7 @@ xfs_end_io_direct(
* handler. * handler.
*/ */
INIT_WORK(&ioend->io_work, xfs_end_bio_written); INIT_WORK(&ioend->io_work, xfs_end_bio_written);
xfs_finish_ioend(ioend); xfs_finish_ioend(ioend, 0);
} }
/* /*
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <linux/freezer.h> #include <linux/freezer.h>
static kmem_zone_t *xfs_buf_zone; static kmem_zone_t *xfs_buf_zone;
static kmem_shaker_t xfs_buf_shake; static struct shrinker *xfs_buf_shake;
STATIC int xfsbufd(void *); STATIC int xfsbufd(void *);
STATIC int xfsbufd_wakeup(int, gfp_t); STATIC int xfsbufd_wakeup(int, gfp_t);
STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int); STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int);
...@@ -314,7 +314,7 @@ xfs_buf_free( ...@@ -314,7 +314,7 @@ xfs_buf_free(
ASSERT(list_empty(&bp->b_hash_list)); ASSERT(list_empty(&bp->b_hash_list));
if (bp->b_flags & _XBF_PAGE_CACHE) { if (bp->b_flags & (_XBF_PAGE_CACHE|_XBF_PAGES)) {
uint i; uint i;
if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1))
...@@ -323,18 +323,11 @@ xfs_buf_free( ...@@ -323,18 +323,11 @@ xfs_buf_free(
for (i = 0; i < bp->b_page_count; i++) { for (i = 0; i < bp->b_page_count; i++) {
struct page *page = bp->b_pages[i]; struct page *page = bp->b_pages[i];
ASSERT(!PagePrivate(page)); if (bp->b_flags & _XBF_PAGE_CACHE)
ASSERT(!PagePrivate(page));
page_cache_release(page); page_cache_release(page);
} }
_xfs_buf_free_pages(bp); _xfs_buf_free_pages(bp);
} else if (bp->b_flags & _XBF_KMEM_ALLOC) {
/*
* XXX(hch): bp->b_count_desired might be incorrect (see
* xfs_buf_associate_memory for details), but fortunately
* the Linux version of kmem_free ignores the len argument..
*/
kmem_free(bp->b_addr, bp->b_count_desired);
_xfs_buf_free_pages(bp);
} }
xfs_buf_deallocate(bp); xfs_buf_deallocate(bp);
...@@ -764,43 +757,44 @@ xfs_buf_get_noaddr( ...@@ -764,43 +757,44 @@ xfs_buf_get_noaddr(
size_t len, size_t len,
xfs_buftarg_t *target) xfs_buftarg_t *target)
{ {
size_t malloc_len = len; unsigned long page_count = PAGE_ALIGN(len) >> PAGE_SHIFT;
int error, i;
xfs_buf_t *bp; xfs_buf_t *bp;
void *data;
int error;
bp = xfs_buf_allocate(0); bp = xfs_buf_allocate(0);
if (unlikely(bp == NULL)) if (unlikely(bp == NULL))
goto fail; goto fail;
_xfs_buf_initialize(bp, target, 0, len, 0); _xfs_buf_initialize(bp, target, 0, len, 0);
try_again: error = _xfs_buf_get_pages(bp, page_count, 0);
data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL | KM_LARGE); if (error)
if (unlikely(data == NULL))
goto fail_free_buf; goto fail_free_buf;
/* check whether alignment matches.. */ for (i = 0; i < page_count; i++) {
if ((__psunsigned_t)data != bp->b_pages[i] = alloc_page(GFP_KERNEL);
((__psunsigned_t)data & ~target->bt_smask)) { if (!bp->b_pages[i])
/* .. else double the size and try again */ goto fail_free_mem;
kmem_free(data, malloc_len);
malloc_len <<= 1;
goto try_again;
} }
bp->b_flags |= _XBF_PAGES;
error = xfs_buf_associate_memory(bp, data, len); error = _xfs_buf_map_pages(bp, XBF_MAPPED);
if (error) if (unlikely(error)) {
printk(KERN_WARNING "%s: failed to map pages\n",
__FUNCTION__);
goto fail_free_mem; goto fail_free_mem;
bp->b_flags |= _XBF_KMEM_ALLOC; }
xfs_buf_unlock(bp); xfs_buf_unlock(bp);
XB_TRACE(bp, "no_daddr", data); XB_TRACE(bp, "no_daddr", len);
return bp; return bp;
fail_free_mem: fail_free_mem:
kmem_free(data, malloc_len); while (--i >= 0)
__free_page(bp->b_pages[i]);
_xfs_buf_free_pages(bp);
fail_free_buf: fail_free_buf:
xfs_buf_free(bp); xfs_buf_deallocate(bp);
fail: fail:
return NULL; return NULL;
} }
...@@ -1453,6 +1447,7 @@ xfs_free_buftarg( ...@@ -1453,6 +1447,7 @@ xfs_free_buftarg(
int external) int external)
{ {
xfs_flush_buftarg(btp, 1); xfs_flush_buftarg(btp, 1);
xfs_blkdev_issue_flush(btp);
if (external) if (external)
xfs_blkdev_put(btp->bt_bdev); xfs_blkdev_put(btp->bt_bdev);
xfs_free_bufhash(btp); xfs_free_bufhash(btp);
...@@ -1837,7 +1832,7 @@ xfs_buf_init(void) ...@@ -1837,7 +1832,7 @@ xfs_buf_init(void)
if (!xfsdatad_workqueue) if (!xfsdatad_workqueue)
goto out_destroy_xfslogd_workqueue; goto out_destroy_xfslogd_workqueue;
xfs_buf_shake = kmem_shake_register(xfsbufd_wakeup); xfs_buf_shake = set_shrinker(DEFAULT_SEEKS, xfsbufd_wakeup);
if (!xfs_buf_shake) if (!xfs_buf_shake)
goto out_destroy_xfsdatad_workqueue; goto out_destroy_xfsdatad_workqueue;
...@@ -1859,7 +1854,7 @@ xfs_buf_init(void) ...@@ -1859,7 +1854,7 @@ xfs_buf_init(void)
void void
xfs_buf_terminate(void) xfs_buf_terminate(void)
{ {
kmem_shake_deregister(xfs_buf_shake); remove_shrinker(xfs_buf_shake);
destroy_workqueue(xfsdatad_workqueue); destroy_workqueue(xfsdatad_workqueue);
destroy_workqueue(xfslogd_workqueue); destroy_workqueue(xfslogd_workqueue);
kmem_zone_destroy(xfs_buf_zone); kmem_zone_destroy(xfs_buf_zone);
......
...@@ -63,7 +63,7 @@ typedef enum { ...@@ -63,7 +63,7 @@ typedef enum {
/* flags used only internally */ /* flags used only internally */
_XBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */ _XBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */
_XBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */ _XBF_PAGES = (1 << 18), /* backed by refcounted pages */
_XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
_XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
} xfs_buf_flags_t; } xfs_buf_flags_t;
......
...@@ -183,15 +183,6 @@ xfs_file_open( ...@@ -183,15 +183,6 @@ xfs_file_open(
return -bhv_vop_open(vn_from_inode(inode), NULL); return -bhv_vop_open(vn_from_inode(inode), NULL);
} }
STATIC int
xfs_file_close(
struct file *filp,
fl_owner_t id)
{
return -bhv_vop_close(vn_from_inode(filp->f_path.dentry->d_inode), 0,
file_count(filp) > 1 ? L_FALSE : L_TRUE, NULL);
}
STATIC int STATIC int
xfs_file_release( xfs_file_release(
struct inode *inode, struct inode *inode,
...@@ -436,7 +427,6 @@ const struct file_operations xfs_file_operations = { ...@@ -436,7 +427,6 @@ const struct file_operations xfs_file_operations = {
#endif #endif
.mmap = xfs_file_mmap, .mmap = xfs_file_mmap,
.open = xfs_file_open, .open = xfs_file_open,
.flush = xfs_file_close,
.release = xfs_file_release, .release = xfs_file_release,
.fsync = xfs_file_fsync, .fsync = xfs_file_fsync,
#ifdef HAVE_FOP_OPEN_EXEC #ifdef HAVE_FOP_OPEN_EXEC
...@@ -458,7 +448,6 @@ const struct file_operations xfs_invis_file_operations = { ...@@ -458,7 +448,6 @@ const struct file_operations xfs_invis_file_operations = {
#endif #endif
.mmap = xfs_file_mmap, .mmap = xfs_file_mmap,
.open = xfs_file_open, .open = xfs_file_open,
.flush = xfs_file_close,
.release = xfs_file_release, .release = xfs_file_release,
.fsync = xfs_file_fsync, .fsync = xfs_file_fsync,
}; };
......
...@@ -46,6 +46,7 @@ xfs_param_t xfs_params = { ...@@ -46,6 +46,7 @@ xfs_param_t xfs_params = {
.inherit_nosym = { 0, 0, 1 }, .inherit_nosym = { 0, 0, 1 },
.rotorstep = { 1, 1, 255 }, .rotorstep = { 1, 1, 255 },
.inherit_nodfrg = { 0, 1, 1 }, .inherit_nodfrg = { 0, 1, 1 },
.fstrm_timer = { 1, 50, 3600*100},
}; };
/* /*
......
...@@ -1019,7 +1019,7 @@ xfs_ioc_bulkstat( ...@@ -1019,7 +1019,7 @@ xfs_ioc_bulkstat(
if (cmd == XFS_IOC_FSINUMBERS) if (cmd == XFS_IOC_FSINUMBERS)
error = xfs_inumbers(mp, &inlast, &count, error = xfs_inumbers(mp, &inlast, &count,
bulkreq.ubuffer); bulkreq.ubuffer, xfs_inumbers_fmt);
else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE) else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE)
error = xfs_bulkstat_single(mp, &inlast, error = xfs_bulkstat_single(mp, &inlast,
bulkreq.ubuffer, &done); bulkreq.ubuffer, &done);
......
...@@ -23,10 +23,25 @@ ...@@ -23,10 +23,25 @@
#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_fs.h" #include "xfs_fs.h"
#include "xfs_bit.h"
#include "xfs_log.h"
#include "xfs_inum.h"
#include "xfs_trans.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_dir2.h"
#include "xfs_dmapi.h"
#include "xfs_mount.h"
#include "xfs_bmap_btree.h"
#include "xfs_attr_sf.h"
#include "xfs_dir2_sf.h"
#include "xfs_vfs.h" #include "xfs_vfs.h"
#include "xfs_vnode.h" #include "xfs_vnode.h"
#include "xfs_dinode.h"
#include "xfs_inode.h"
#include "xfs_itable.h"
#include "xfs_error.h"
#include "xfs_dfrag.h" #include "xfs_dfrag.h"
#define _NATIVE_IOC(cmd, type) \ #define _NATIVE_IOC(cmd, type) \
...@@ -34,6 +49,7 @@ ...@@ -34,6 +49,7 @@
#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
#define BROKEN_X86_ALIGNMENT #define BROKEN_X86_ALIGNMENT
#define _PACKED __attribute__((packed))
/* on ia32 l_start is on a 32-bit boundary */ /* on ia32 l_start is on a 32-bit boundary */
typedef struct xfs_flock64_32 { typedef struct xfs_flock64_32 {
__s16 l_type; __s16 l_type;
...@@ -75,35 +91,276 @@ xfs_ioctl32_flock( ...@@ -75,35 +91,276 @@ xfs_ioctl32_flock(
return (unsigned long)p; return (unsigned long)p;
} }
typedef struct compat_xfs_fsop_geom_v1 {
__u32 blocksize; /* filesystem (data) block size */
__u32 rtextsize; /* realtime extent size */
__u32 agblocks; /* fsblocks in an AG */
__u32 agcount; /* number of allocation groups */
__u32 logblocks; /* fsblocks in the log */
__u32 sectsize; /* (data) sector size, bytes */
__u32 inodesize; /* inode size in bytes */
__u32 imaxpct; /* max allowed inode space(%) */
__u64 datablocks; /* fsblocks in data subvolume */
__u64 rtblocks; /* fsblocks in realtime subvol */
__u64 rtextents; /* rt extents in realtime subvol*/
__u64 logstart; /* starting fsblock of the log */
unsigned char uuid[16]; /* unique id of the filesystem */
__u32 sunit; /* stripe unit, fsblocks */
__u32 swidth; /* stripe width, fsblocks */
__s32 version; /* structure version */
__u32 flags; /* superblock version flags */
__u32 logsectsize; /* log sector size, bytes */
__u32 rtsectsize; /* realtime sector size, bytes */
__u32 dirblocksize; /* directory block size, bytes */
} __attribute__((packed)) compat_xfs_fsop_geom_v1_t;
#define XFS_IOC_FSGEOMETRY_V1_32 \
_IOR ('X', 100, struct compat_xfs_fsop_geom_v1)
STATIC unsigned long xfs_ioctl32_geom_v1(unsigned long arg)
{
compat_xfs_fsop_geom_v1_t __user *p32 = (void __user *)arg;
xfs_fsop_geom_v1_t __user *p = compat_alloc_user_space(sizeof(*p));
if (copy_in_user(p, p32, sizeof(*p32)))
return -EFAULT;
return (unsigned long)p;
}
typedef struct compat_xfs_inogrp {
__u64 xi_startino; /* starting inode number */
__s32 xi_alloccount; /* # bits set in allocmask */
__u64 xi_allocmask; /* mask of allocated inodes */
} __attribute__((packed)) compat_xfs_inogrp_t;
STATIC int xfs_inumbers_fmt_compat(
void __user *ubuffer,
const xfs_inogrp_t *buffer,
long count,
long *written)
{
compat_xfs_inogrp_t *p32 = ubuffer;
long i;
for (i = 0; i < count; i++) {
if (put_user(buffer[i].xi_startino, &p32[i].xi_startino) ||
put_user(buffer[i].xi_alloccount, &p32[i].xi_alloccount) ||
put_user(buffer[i].xi_allocmask, &p32[i].xi_allocmask))
return -EFAULT;
}
*written = count * sizeof(*p32);
return 0;
}
#else #else
typedef struct xfs_fsop_bulkreq32 { #define xfs_inumbers_fmt_compat xfs_inumbers_fmt
#define _PACKED
#endif
/* XFS_IOC_FSBULKSTAT and friends */
typedef struct compat_xfs_bstime {
__s32 tv_sec; /* seconds */
__s32 tv_nsec; /* and nanoseconds */
} compat_xfs_bstime_t;
STATIC int xfs_bstime_store_compat(
compat_xfs_bstime_t __user *p32,
const xfs_bstime_t *p)
{
__s32 sec32;
sec32 = p->tv_sec;
if (put_user(sec32, &p32->tv_sec) ||
put_user(p->tv_nsec, &p32->tv_nsec))
return -EFAULT;
return 0;
}
typedef struct compat_xfs_bstat {
__u64 bs_ino; /* inode number */
__u16 bs_mode; /* type and mode */
__u16 bs_nlink; /* number of links */
__u32 bs_uid; /* user id */
__u32 bs_gid; /* group id */
__u32 bs_rdev; /* device value */
__s32 bs_blksize; /* block size */
__s64 bs_size; /* file size */
compat_xfs_bstime_t bs_atime; /* access time */
compat_xfs_bstime_t bs_mtime; /* modify time */
compat_xfs_bstime_t bs_ctime; /* inode change time */
int64_t bs_blocks; /* number of blocks */
__u32 bs_xflags; /* extended flags */
__s32 bs_extsize; /* extent size */
__s32 bs_extents; /* number of extents */
__u32 bs_gen; /* generation count */
__u16 bs_projid; /* project id */
unsigned char bs_pad[14]; /* pad space, unused */
__u32 bs_dmevmask; /* DMIG event mask */
__u16 bs_dmstate; /* DMIG state info */
__u16 bs_aextents; /* attribute number of extents */
} _PACKED compat_xfs_bstat_t;
STATIC int xfs_bulkstat_one_fmt_compat(
void __user *ubuffer,
const xfs_bstat_t *buffer)
{
compat_xfs_bstat_t __user *p32 = ubuffer;
if (put_user(buffer->bs_ino, &p32->bs_ino) ||
put_user(buffer->bs_mode, &p32->bs_mode) ||
put_user(buffer->bs_nlink, &p32->bs_nlink) ||
put_user(buffer->bs_uid, &p32->bs_uid) ||
put_user(buffer->bs_gid, &p32->bs_gid) ||
put_user(buffer->bs_rdev, &p32->bs_rdev) ||
put_user(buffer->bs_blksize, &p32->bs_blksize) ||
put_user(buffer->bs_size, &p32->bs_size) ||
xfs_bstime_store_compat(&p32->bs_atime, &buffer->bs_atime) ||
xfs_bstime_store_compat(&p32->bs_mtime, &buffer->bs_mtime) ||
xfs_bstime_store_compat(&p32->bs_ctime, &buffer->bs_ctime) ||
put_user(buffer->bs_blocks, &p32->bs_blocks) ||
put_user(buffer->bs_xflags, &p32->bs_xflags) ||
put_user(buffer->bs_extsize, &p32->bs_extsize) ||
put_user(buffer->bs_extents, &p32->bs_extents) ||
put_user(buffer->bs_gen, &p32->bs_gen) ||
put_user(buffer->bs_projid, &p32->bs_projid) ||
put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) ||
put_user(buffer->bs_dmstate, &p32->bs_dmstate) ||
put_user(buffer->bs_aextents, &p32->bs_aextents))
return -EFAULT;
return sizeof(*p32);
}
typedef struct compat_xfs_fsop_bulkreq {
compat_uptr_t lastip; /* last inode # pointer */ compat_uptr_t lastip; /* last inode # pointer */
__s32 icount; /* count of entries in buffer */ __s32 icount; /* count of entries in buffer */
compat_uptr_t ubuffer; /* user buffer for inode desc. */ compat_uptr_t ubuffer; /* user buffer for inode desc. */
__s32 ocount; /* output count pointer */ compat_uptr_t ocount; /* output count pointer */
} xfs_fsop_bulkreq32_t; } compat_xfs_fsop_bulkreq_t;
STATIC unsigned long #define XFS_IOC_FSBULKSTAT_32 \
xfs_ioctl32_bulkstat( _IOWR('X', 101, struct compat_xfs_fsop_bulkreq)
unsigned long arg) #define XFS_IOC_FSBULKSTAT_SINGLE_32 \
_IOWR('X', 102, struct compat_xfs_fsop_bulkreq)
#define XFS_IOC_FSINUMBERS_32 \
_IOWR('X', 103, struct compat_xfs_fsop_bulkreq)
/* copied from xfs_ioctl.c */
STATIC int
xfs_ioc_bulkstat_compat(
xfs_mount_t *mp,
unsigned int cmd,
void __user *arg)
{ {
xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg; compat_xfs_fsop_bulkreq_t __user *p32 = (void __user *)arg;
xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p));
u32 addr; u32 addr;
xfs_fsop_bulkreq_t bulkreq;
int count; /* # of records returned */
xfs_ino_t inlast; /* last inode number */
int done;
int error;
/* done = 1 if there are more stats to get and if bulkstat */
/* should be called again (unused here, but used in dmapi) */
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO);
if (get_user(addr, &p32->lastip))
return -EFAULT;
bulkreq.lastip = compat_ptr(addr);
if (get_user(bulkreq.icount, &p32->icount) ||
get_user(addr, &p32->ubuffer))
return -EFAULT;
bulkreq.ubuffer = compat_ptr(addr);
if (get_user(addr, &p32->ocount))
return -EFAULT;
bulkreq.ocount = compat_ptr(addr);
if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64)))
return -XFS_ERROR(EFAULT);
if ((count = bulkreq.icount) <= 0)
return -XFS_ERROR(EINVAL);
if (cmd == XFS_IOC_FSINUMBERS)
error = xfs_inumbers(mp, &inlast, &count,
bulkreq.ubuffer, xfs_inumbers_fmt_compat);
else {
/* declare a var to get a warning in case the type changes */
bulkstat_one_fmt_pf formatter = xfs_bulkstat_one_fmt_compat;
error = xfs_bulkstat(mp, &inlast, &count,
xfs_bulkstat_one, formatter,
sizeof(compat_xfs_bstat_t), bulkreq.ubuffer,
BULKSTAT_FG_QUICK, &done);
}
if (error)
return -error;
if (bulkreq.ocount != NULL) {
if (copy_to_user(bulkreq.lastip, &inlast,
sizeof(xfs_ino_t)))
return -XFS_ERROR(EFAULT);
if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
return -XFS_ERROR(EFAULT);
}
return 0;
}
typedef struct compat_xfs_fsop_handlereq {
__u32 fd; /* fd for FD_TO_HANDLE */
compat_uptr_t path; /* user pathname */
__u32 oflags; /* open flags */
compat_uptr_t ihandle; /* user supplied handle */
__u32 ihandlen; /* user supplied length */
compat_uptr_t ohandle; /* user buffer for handle */
compat_uptr_t ohandlen; /* user buffer length */
} compat_xfs_fsop_handlereq_t;
#define XFS_IOC_PATH_TO_FSHANDLE_32 \
_IOWR('X', 104, struct compat_xfs_fsop_handlereq)
#define XFS_IOC_PATH_TO_HANDLE_32 \
_IOWR('X', 105, struct compat_xfs_fsop_handlereq)
#define XFS_IOC_FD_TO_HANDLE_32 \
_IOWR('X', 106, struct compat_xfs_fsop_handlereq)
#define XFS_IOC_OPEN_BY_HANDLE_32 \
_IOWR('X', 107, struct compat_xfs_fsop_handlereq)
#define XFS_IOC_READLINK_BY_HANDLE_32 \
_IOWR('X', 108, struct compat_xfs_fsop_handlereq)
STATIC unsigned long xfs_ioctl32_fshandle(unsigned long arg)
{
compat_xfs_fsop_handlereq_t __user *p32 = (void __user *)arg;
xfs_fsop_handlereq_t __user *p = compat_alloc_user_space(sizeof(*p));
u32 addr;
if (get_user(addr, &p32->lastip) || if (copy_in_user(&p->fd, &p32->fd, sizeof(__u32)) ||
put_user(compat_ptr(addr), &p->lastip) || get_user(addr, &p32->path) ||
copy_in_user(&p->icount, &p32->icount, sizeof(s32)) || put_user(compat_ptr(addr), &p->path) ||
get_user(addr, &p32->ubuffer) || copy_in_user(&p->oflags, &p32->oflags, sizeof(__u32)) ||
put_user(compat_ptr(addr), &p->ubuffer) || get_user(addr, &p32->ihandle) ||
get_user(addr, &p32->ocount) || put_user(compat_ptr(addr), &p->ihandle) ||
put_user(compat_ptr(addr), &p->ocount)) copy_in_user(&p->ihandlen, &p32->ihandlen, sizeof(__u32)) ||
get_user(addr, &p32->ohandle) ||
put_user(compat_ptr(addr), &p->ohandle) ||
get_user(addr, &p32->ohandlen) ||
put_user(compat_ptr(addr), &p->ohandlen))
return -EFAULT; return -EFAULT;
return (unsigned long)p; return (unsigned long)p;
} }
#endif
STATIC long STATIC long
xfs_compat_ioctl( xfs_compat_ioctl(
...@@ -118,7 +375,6 @@ xfs_compat_ioctl( ...@@ -118,7 +375,6 @@ xfs_compat_ioctl(
switch (cmd) { switch (cmd) {
case XFS_IOC_DIOINFO: case XFS_IOC_DIOINFO:
case XFS_IOC_FSGEOMETRY_V1:
case XFS_IOC_FSGEOMETRY: case XFS_IOC_FSGEOMETRY:
case XFS_IOC_GETVERSION: case XFS_IOC_GETVERSION:
case XFS_IOC_GETXFLAGS: case XFS_IOC_GETXFLAGS:
...@@ -131,12 +387,7 @@ xfs_compat_ioctl( ...@@ -131,12 +387,7 @@ xfs_compat_ioctl(
case XFS_IOC_GETBMAPA: case XFS_IOC_GETBMAPA:
case XFS_IOC_GETBMAPX: case XFS_IOC_GETBMAPX:
/* not handled /* not handled
case XFS_IOC_FD_TO_HANDLE:
case XFS_IOC_PATH_TO_HANDLE:
case XFS_IOC_PATH_TO_FSHANDLE:
case XFS_IOC_OPEN_BY_HANDLE:
case XFS_IOC_FSSETDM_BY_HANDLE: case XFS_IOC_FSSETDM_BY_HANDLE:
case XFS_IOC_READLINK_BY_HANDLE:
case XFS_IOC_ATTRLIST_BY_HANDLE: case XFS_IOC_ATTRLIST_BY_HANDLE:
case XFS_IOC_ATTRMULTI_BY_HANDLE: case XFS_IOC_ATTRMULTI_BY_HANDLE:
*/ */
...@@ -166,6 +417,10 @@ xfs_compat_ioctl( ...@@ -166,6 +417,10 @@ xfs_compat_ioctl(
arg = xfs_ioctl32_flock(arg); arg = xfs_ioctl32_flock(arg);
cmd = _NATIVE_IOC(cmd, struct xfs_flock64); cmd = _NATIVE_IOC(cmd, struct xfs_flock64);
break; break;
case XFS_IOC_FSGEOMETRY_V1_32:
arg = xfs_ioctl32_geom_v1(arg);
cmd = _NATIVE_IOC(cmd, struct xfs_fsop_geom_v1);
break;
#else /* These are handled fine if no alignment issues */ #else /* These are handled fine if no alignment issues */
case XFS_IOC_ALLOCSP: case XFS_IOC_ALLOCSP:
...@@ -176,18 +431,28 @@ xfs_compat_ioctl( ...@@ -176,18 +431,28 @@ xfs_compat_ioctl(
case XFS_IOC_FREESP64: case XFS_IOC_FREESP64:
case XFS_IOC_RESVSP64: case XFS_IOC_RESVSP64:
case XFS_IOC_UNRESVSP64: case XFS_IOC_UNRESVSP64:
case XFS_IOC_FSGEOMETRY_V1:
break; break;
/* xfs_bstat_t still has wrong u32 vs u64 alignment */ /* xfs_bstat_t still has wrong u32 vs u64 alignment */
case XFS_IOC_SWAPEXT: case XFS_IOC_SWAPEXT:
break; break;
case XFS_IOC_FSBULKSTAT_SINGLE:
case XFS_IOC_FSBULKSTAT:
case XFS_IOC_FSINUMBERS:
arg = xfs_ioctl32_bulkstat(arg);
break;
#endif #endif
case XFS_IOC_FSBULKSTAT_32:
case XFS_IOC_FSBULKSTAT_SINGLE_32:
case XFS_IOC_FSINUMBERS_32:
cmd = _NATIVE_IOC(cmd, struct xfs_fsop_bulkreq);
return xfs_ioc_bulkstat_compat(XFS_BHVTOI(VNHEAD(vp))->i_mount,
cmd, (void*)arg);
case XFS_IOC_FD_TO_HANDLE_32:
case XFS_IOC_PATH_TO_HANDLE_32:
case XFS_IOC_PATH_TO_FSHANDLE_32:
case XFS_IOC_OPEN_BY_HANDLE_32:
case XFS_IOC_READLINK_BY_HANDLE_32:
arg = xfs_ioctl32_fshandle(arg);
cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);
break;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val #define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
#define xfs_rotorstep xfs_params.rotorstep.val #define xfs_rotorstep xfs_params.rotorstep.val
#define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val #define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val
#define xfs_fstrm_centisecs xfs_params.fstrm_timer.val
#define current_cpu() (raw_smp_processor_id()) #define current_cpu() (raw_smp_processor_id())
#define current_pid() (current->pid) #define current_pid() (current->pid)
......
...@@ -547,7 +547,8 @@ vfs_sync_worker( ...@@ -547,7 +547,8 @@ vfs_sync_worker(
if (!(vfsp->vfs_flag & VFS_RDONLY)) if (!(vfsp->vfs_flag & VFS_RDONLY))
error = bhv_vfs_sync(vfsp, SYNC_FSDATA | SYNC_BDFLUSH | \ error = bhv_vfs_sync(vfsp, SYNC_FSDATA | SYNC_BDFLUSH | \
SYNC_ATTR | SYNC_REFCACHE, NULL); SYNC_ATTR | SYNC_REFCACHE | SYNC_SUPER,
NULL);
vfsp->vfs_sync_seq++; vfsp->vfs_sync_seq++;
wake_up(&vfsp->vfs_wait_single_sync_task); wake_up(&vfsp->vfs_wait_single_sync_task);
} }
...@@ -663,7 +664,7 @@ xfs_fs_sync_super( ...@@ -663,7 +664,7 @@ xfs_fs_sync_super(
* occur here so don't bother flushing the buftarg (i.e * occur here so don't bother flushing the buftarg (i.e
* SYNC_QUIESCE) because it'll just get dirty again. * SYNC_QUIESCE) because it'll just get dirty again.
*/ */
flags = SYNC_FSDATA | SYNC_DELWRI | SYNC_WAIT | SYNC_IOWAIT; flags = SYNC_DATA_QUIESCE;
} else } else
flags = SYNC_FSDATA | (wait ? SYNC_WAIT : 0); flags = SYNC_FSDATA | (wait ? SYNC_WAIT : 0);
......
...@@ -210,6 +210,17 @@ static ctl_table xfs_table[] = { ...@@ -210,6 +210,17 @@ static ctl_table xfs_table[] = {
.extra1 = &xfs_params.inherit_nodfrg.min, .extra1 = &xfs_params.inherit_nodfrg.min,
.extra2 = &xfs_params.inherit_nodfrg.max .extra2 = &xfs_params.inherit_nodfrg.max
}, },
{
.ctl_name = XFS_FILESTREAM_TIMER,
.procname = "filestream_centisecs",
.data = &xfs_params.fstrm_timer.val,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec_minmax,
.strategy = &sysctl_intvec,
.extra1 = &xfs_params.fstrm_timer.min,
.extra2 = &xfs_params.fstrm_timer.max,
},
/* please keep this the last entry */ /* please keep this the last entry */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
{ {
......
...@@ -47,6 +47,7 @@ typedef struct xfs_param { ...@@ -47,6 +47,7 @@ typedef struct xfs_param {
xfs_sysctl_val_t inherit_nosym; /* Inherit the "nosymlinks" flag. */ xfs_sysctl_val_t inherit_nosym; /* Inherit the "nosymlinks" flag. */
xfs_sysctl_val_t rotorstep; /* inode32 AG rotoring control knob */ xfs_sysctl_val_t rotorstep; /* inode32 AG rotoring control knob */
xfs_sysctl_val_t inherit_nodfrg;/* Inherit the "nodefrag" inode flag. */ xfs_sysctl_val_t inherit_nodfrg;/* Inherit the "nodefrag" inode flag. */
xfs_sysctl_val_t fstrm_timer; /* Filestream dir-AG assoc'n timeout. */
} xfs_param_t; } xfs_param_t;
/* /*
...@@ -86,6 +87,7 @@ enum { ...@@ -86,6 +87,7 @@ enum {
XFS_INHERIT_NOSYM = 19, XFS_INHERIT_NOSYM = 19,
XFS_ROTORSTEP = 20, XFS_ROTORSTEP = 20,
XFS_INHERIT_NODFRG = 21, XFS_INHERIT_NODFRG = 21,
XFS_FILESTREAM_TIMER = 22,
}; };
extern xfs_param_t xfs_params; extern xfs_param_t xfs_params;
......
...@@ -92,6 +92,21 @@ typedef enum { ...@@ -92,6 +92,21 @@ typedef enum {
#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ #define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ #define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
#define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */ #define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */
#define SYNC_SUPER 0x0200 /* flush superblock to disk */
/*
* When remounting a filesystem read-only or freezing the filesystem,
* we have two phases to execute. This first phase is syncing the data
* before we quiesce the fielsystem, and the second is flushing all the
* inodes out after we've waited for all the transactions created by
* the first phase to complete. The second phase uses SYNC_INODE_QUIESCE
* to ensure that the inodes are written to their location on disk
* rather than just existing in transactions in the log. This means
* after a quiesce there is no log replay required to write the inodes
* to disk (this is the main difference between a sync and a quiesce).
*/
#define SYNC_DATA_QUIESCE (SYNC_DELWRI|SYNC_FSDATA|SYNC_WAIT|SYNC_IOWAIT)
#define SYNC_INODE_QUIESCE (SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT)
#define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */ #define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */
#define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */ #define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */
......
...@@ -129,10 +129,7 @@ typedef enum bhv_vchange { ...@@ -129,10 +129,7 @@ typedef enum bhv_vchange {
VCHANGE_FLAGS_IOEXCL_COUNT = 4 VCHANGE_FLAGS_IOEXCL_COUNT = 4
} bhv_vchange_t; } bhv_vchange_t;
typedef enum { L_FALSE, L_TRUE } lastclose_t;
typedef int (*vop_open_t)(bhv_desc_t *, struct cred *); typedef int (*vop_open_t)(bhv_desc_t *, struct cred *);
typedef int (*vop_close_t)(bhv_desc_t *, int, lastclose_t, struct cred *);
typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *, typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
const struct iovec *, unsigned int, const struct iovec *, unsigned int,
loff_t *, int, struct cred *); loff_t *, int, struct cred *);
...@@ -200,7 +197,6 @@ typedef int (*vop_iflush_t)(bhv_desc_t *, int); ...@@ -200,7 +197,6 @@ typedef int (*vop_iflush_t)(bhv_desc_t *, int);
typedef struct bhv_vnodeops { typedef struct bhv_vnodeops {
bhv_position_t vn_position; /* position within behavior chain */ bhv_position_t vn_position; /* position within behavior chain */
vop_open_t vop_open; vop_open_t vop_open;
vop_close_t vop_close;
vop_read_t vop_read; vop_read_t vop_read;
vop_write_t vop_write; vop_write_t vop_write;
vop_splice_read_t vop_splice_read; vop_splice_read_t vop_splice_read;
...@@ -245,7 +241,6 @@ typedef struct bhv_vnodeops { ...@@ -245,7 +241,6 @@ typedef struct bhv_vnodeops {
#define VNHEAD(vp) ((vp)->v_bh.bh_first) #define VNHEAD(vp) ((vp)->v_bh.bh_first)
#define VOP(op, vp) (*((bhv_vnodeops_t *)VNHEAD(vp)->bd_ops)->op) #define VOP(op, vp) (*((bhv_vnodeops_t *)VNHEAD(vp)->bd_ops)->op)
#define bhv_vop_open(vp, cr) VOP(vop_open, vp)(VNHEAD(vp),cr) #define bhv_vop_open(vp, cr) VOP(vop_open, vp)(VNHEAD(vp),cr)
#define bhv_vop_close(vp, f,last,cr) VOP(vop_close, vp)(VNHEAD(vp),f,last,cr)
#define bhv_vop_read(vp,file,iov,segs,offset,ioflags,cr) \ #define bhv_vop_read(vp,file,iov,segs,offset,ioflags,cr) \
VOP(vop_read, vp)(VNHEAD(vp),file,iov,segs,offset,ioflags,cr) VOP(vop_read, vp)(VNHEAD(vp),file,iov,segs,offset,ioflags,cr)
#define bhv_vop_write(vp,file,iov,segs,offset,ioflags,cr) \ #define bhv_vop_write(vp,file,iov,segs,offset,ioflags,cr) \
......
...@@ -62,10 +62,9 @@ uint ndquot; ...@@ -62,10 +62,9 @@ uint ndquot;
kmem_zone_t *qm_dqzone; kmem_zone_t *qm_dqzone;
kmem_zone_t *qm_dqtrxzone; kmem_zone_t *qm_dqtrxzone;
static kmem_shaker_t xfs_qm_shaker; static struct shrinker *xfs_qm_shaker;
static cred_t xfs_zerocr; static cred_t xfs_zerocr;
static xfs_inode_t xfs_zeroino;
STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int);
STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
...@@ -150,7 +149,7 @@ xfs_Gqm_init(void) ...@@ -150,7 +149,7 @@ xfs_Gqm_init(void)
} else } else
xqm->qm_dqzone = qm_dqzone; xqm->qm_dqzone = qm_dqzone;
xfs_qm_shaker = kmem_shake_register(xfs_qm_shake); xfs_qm_shaker = set_shrinker(DEFAULT_SEEKS, xfs_qm_shake);
/* /*
* The t_dqinfo portion of transactions. * The t_dqinfo portion of transactions.
...@@ -182,7 +181,7 @@ xfs_qm_destroy( ...@@ -182,7 +181,7 @@ xfs_qm_destroy(
ASSERT(xqm != NULL); ASSERT(xqm != NULL);
ASSERT(xqm->qm_nrefs == 0); ASSERT(xqm->qm_nrefs == 0);
kmem_shake_deregister(xfs_qm_shaker); remove_shrinker(xfs_qm_shaker);
hsize = xqm->qm_dqhashmask + 1; hsize = xqm->qm_dqhashmask + 1;
for (i = 0; i < hsize; i++) { for (i = 0; i < hsize; i++) {
xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i])); xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i]));
...@@ -1415,7 +1414,7 @@ xfs_qm_qino_alloc( ...@@ -1415,7 +1414,7 @@ xfs_qm_qino_alloc(
return error; return error;
} }
if ((error = xfs_dir_ialloc(&tp, &xfs_zeroino, S_IFREG, 1, 0, if ((error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0,
&xfs_zerocr, 0, 1, ip, &committed))) { &xfs_zerocr, 0, 1, ip, &committed))) {
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
XFS_TRANS_ABORT); XFS_TRANS_ABORT);
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#define XFS_RW_TRACE 1 #define XFS_RW_TRACE 1
#define XFS_BUF_TRACE 1 #define XFS_BUF_TRACE 1
#define XFS_VNODE_TRACE 1 #define XFS_VNODE_TRACE 1
#define XFS_FILESTREAMS_TRACE 1
#endif #endif
#include <linux-2.6/xfs_linux.h> #include <linux-2.6/xfs_linux.h>
......
...@@ -68,6 +68,7 @@ typedef struct xfs_agf { ...@@ -68,6 +68,7 @@ typedef struct xfs_agf {
__be32 agf_flcount; /* count of blocks in freelist */ __be32 agf_flcount; /* count of blocks in freelist */
__be32 agf_freeblks; /* total free blocks */ __be32 agf_freeblks; /* total free blocks */
__be32 agf_longest; /* longest free space */ __be32 agf_longest; /* longest free space */
__be32 agf_btreeblks; /* # of blocks held in AGF btrees */
} xfs_agf_t; } xfs_agf_t;
#define XFS_AGF_MAGICNUM 0x00000001 #define XFS_AGF_MAGICNUM 0x00000001
...@@ -81,7 +82,8 @@ typedef struct xfs_agf { ...@@ -81,7 +82,8 @@ typedef struct xfs_agf {
#define XFS_AGF_FLCOUNT 0x00000100 #define XFS_AGF_FLCOUNT 0x00000100
#define XFS_AGF_FREEBLKS 0x00000200 #define XFS_AGF_FREEBLKS 0x00000200
#define XFS_AGF_LONGEST 0x00000400 #define XFS_AGF_LONGEST 0x00000400
#define XFS_AGF_NUM_BITS 11 #define XFS_AGF_BTREEBLKS 0x00000800
#define XFS_AGF_NUM_BITS 12
#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
/* disk block (xfs_daddr_t) in the AG */ /* disk block (xfs_daddr_t) in the AG */
...@@ -186,12 +188,15 @@ typedef struct xfs_perag ...@@ -186,12 +188,15 @@ typedef struct xfs_perag
__uint32_t pagf_flcount; /* count of blocks in freelist */ __uint32_t pagf_flcount; /* count of blocks in freelist */
xfs_extlen_t pagf_freeblks; /* total free blocks */ xfs_extlen_t pagf_freeblks; /* total free blocks */
xfs_extlen_t pagf_longest; /* longest free space */ xfs_extlen_t pagf_longest; /* longest free space */
__uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */
xfs_agino_t pagi_freecount; /* number of free inodes */ xfs_agino_t pagi_freecount; /* number of free inodes */
xfs_agino_t pagi_count; /* number of allocated inodes */
int pagb_count; /* pagb slots in use */
#ifdef __KERNEL__ #ifdef __KERNEL__
lock_t pagb_lock; /* lock for pagb_list */ lock_t pagb_lock; /* lock for pagb_list */
#endif #endif
int pagb_count; /* pagb slots in use */
xfs_perag_busy_t *pagb_list; /* unstable blocks */ xfs_perag_busy_t *pagb_list; /* unstable blocks */
atomic_t pagf_fstrms; /* # of filestreams active in this AG */
} xfs_perag_t; } xfs_perag_t;
#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
......
...@@ -55,17 +55,17 @@ xfs_alloc_search_busy(xfs_trans_t *tp, ...@@ -55,17 +55,17 @@ xfs_alloc_search_busy(xfs_trans_t *tp,
ktrace_t *xfs_alloc_trace_buf; ktrace_t *xfs_alloc_trace_buf;
#define TRACE_ALLOC(s,a) \ #define TRACE_ALLOC(s,a) \
xfs_alloc_trace_alloc(fname, s, a, __LINE__) xfs_alloc_trace_alloc(__FUNCTION__, s, a, __LINE__)
#define TRACE_FREE(s,a,b,x,f) \ #define TRACE_FREE(s,a,b,x,f) \
xfs_alloc_trace_free(fname, s, mp, a, b, x, f, __LINE__) xfs_alloc_trace_free(__FUNCTION__, s, mp, a, b, x, f, __LINE__)
#define TRACE_MODAGF(s,a,f) \ #define TRACE_MODAGF(s,a,f) \
xfs_alloc_trace_modagf(fname, s, mp, a, f, __LINE__) xfs_alloc_trace_modagf(__FUNCTION__, s, mp, a, f, __LINE__)
#define TRACE_BUSY(fname,s,ag,agb,l,sl,tp) \ #define TRACE_BUSY(__FUNCTION__,s,ag,agb,l,sl,tp) \
xfs_alloc_trace_busy(fname, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSY, __LINE__) xfs_alloc_trace_busy(__FUNCTION__, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSY, __LINE__)
#define TRACE_UNBUSY(fname,s,ag,sl,tp) \ #define TRACE_UNBUSY(__FUNCTION__,s,ag,sl,tp) \
xfs_alloc_trace_busy(fname, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__) xfs_alloc_trace_busy(__FUNCTION__, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__)
#define TRACE_BUSYSEARCH(fname,s,ag,agb,l,sl,tp) \ #define TRACE_BUSYSEARCH(__FUNCTION__,s,ag,agb,l,sl,tp) \
xfs_alloc_trace_busy(fname, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__) xfs_alloc_trace_busy(__FUNCTION__, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__)
#else #else
#define TRACE_ALLOC(s,a) #define TRACE_ALLOC(s,a)
#define TRACE_FREE(s,a,b,x,f) #define TRACE_FREE(s,a,b,x,f)
...@@ -420,7 +420,7 @@ xfs_alloc_read_agfl( ...@@ -420,7 +420,7 @@ xfs_alloc_read_agfl(
*/ */
STATIC void STATIC void
xfs_alloc_trace_alloc( xfs_alloc_trace_alloc(
char *name, /* function tag string */ const char *name, /* function tag string */
char *str, /* additional string */ char *str, /* additional string */
xfs_alloc_arg_t *args, /* allocation argument structure */ xfs_alloc_arg_t *args, /* allocation argument structure */
int line) /* source line number */ int line) /* source line number */
...@@ -453,7 +453,7 @@ xfs_alloc_trace_alloc( ...@@ -453,7 +453,7 @@ xfs_alloc_trace_alloc(
*/ */
STATIC void STATIC void
xfs_alloc_trace_free( xfs_alloc_trace_free(
char *name, /* function tag string */ const char *name, /* function tag string */
char *str, /* additional string */ char *str, /* additional string */
xfs_mount_t *mp, /* file system mount point */ xfs_mount_t *mp, /* file system mount point */
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
...@@ -479,7 +479,7 @@ xfs_alloc_trace_free( ...@@ -479,7 +479,7 @@ xfs_alloc_trace_free(
*/ */
STATIC void STATIC void
xfs_alloc_trace_modagf( xfs_alloc_trace_modagf(
char *name, /* function tag string */ const char *name, /* function tag string */
char *str, /* additional string */ char *str, /* additional string */
xfs_mount_t *mp, /* file system mount point */ xfs_mount_t *mp, /* file system mount point */
xfs_agf_t *agf, /* new agf value */ xfs_agf_t *agf, /* new agf value */
...@@ -507,7 +507,7 @@ xfs_alloc_trace_modagf( ...@@ -507,7 +507,7 @@ xfs_alloc_trace_modagf(
STATIC void STATIC void
xfs_alloc_trace_busy( xfs_alloc_trace_busy(
char *name, /* function tag string */ const char *name, /* function tag string */
char *str, /* additional string */ char *str, /* additional string */
xfs_mount_t *mp, /* file system mount point */ xfs_mount_t *mp, /* file system mount point */
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
...@@ -549,9 +549,6 @@ xfs_alloc_ag_vextent( ...@@ -549,9 +549,6 @@ xfs_alloc_ag_vextent(
xfs_alloc_arg_t *args) /* argument structure for allocation */ xfs_alloc_arg_t *args) /* argument structure for allocation */
{ {
int error=0; int error=0;
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_ag_vextent";
#endif
ASSERT(args->minlen > 0); ASSERT(args->minlen > 0);
ASSERT(args->maxlen > 0); ASSERT(args->maxlen > 0);
...@@ -635,9 +632,6 @@ xfs_alloc_ag_vextent_exact( ...@@ -635,9 +632,6 @@ xfs_alloc_ag_vextent_exact(
xfs_agblock_t fbno; /* start block of found extent */ xfs_agblock_t fbno; /* start block of found extent */
xfs_agblock_t fend; /* end block of found extent */ xfs_agblock_t fend; /* end block of found extent */
xfs_extlen_t flen; /* length of found extent */ xfs_extlen_t flen; /* length of found extent */
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_ag_vextent_exact";
#endif
int i; /* success/failure of operation */ int i; /* success/failure of operation */
xfs_agblock_t maxend; /* end of maximal extent */ xfs_agblock_t maxend; /* end of maximal extent */
xfs_agblock_t minend; /* end of minimal extent */ xfs_agblock_t minend; /* end of minimal extent */
...@@ -737,9 +731,6 @@ xfs_alloc_ag_vextent_near( ...@@ -737,9 +731,6 @@ xfs_alloc_ag_vextent_near(
xfs_btree_cur_t *bno_cur_gt; /* cursor for bno btree, right side */ xfs_btree_cur_t *bno_cur_gt; /* cursor for bno btree, right side */
xfs_btree_cur_t *bno_cur_lt; /* cursor for bno btree, left side */ xfs_btree_cur_t *bno_cur_lt; /* cursor for bno btree, left side */
xfs_btree_cur_t *cnt_cur; /* cursor for count btree */ xfs_btree_cur_t *cnt_cur; /* cursor for count btree */
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_ag_vextent_near";
#endif
xfs_agblock_t gtbno; /* start bno of right side entry */ xfs_agblock_t gtbno; /* start bno of right side entry */
xfs_agblock_t gtbnoa; /* aligned ... */ xfs_agblock_t gtbnoa; /* aligned ... */
xfs_extlen_t gtdiff; /* difference to right side entry */ xfs_extlen_t gtdiff; /* difference to right side entry */
...@@ -1270,9 +1261,6 @@ xfs_alloc_ag_vextent_size( ...@@ -1270,9 +1261,6 @@ xfs_alloc_ag_vextent_size(
int error; /* error result */ int error; /* error result */
xfs_agblock_t fbno; /* start of found freespace */ xfs_agblock_t fbno; /* start of found freespace */
xfs_extlen_t flen; /* length of found freespace */ xfs_extlen_t flen; /* length of found freespace */
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_ag_vextent_size";
#endif
int i; /* temp status variable */ int i; /* temp status variable */
xfs_agblock_t rbno; /* returned block number */ xfs_agblock_t rbno; /* returned block number */
xfs_extlen_t rlen; /* length of returned extent */ xfs_extlen_t rlen; /* length of returned extent */
...@@ -1427,9 +1415,6 @@ xfs_alloc_ag_vextent_small( ...@@ -1427,9 +1415,6 @@ xfs_alloc_ag_vextent_small(
int error; int error;
xfs_agblock_t fbno; xfs_agblock_t fbno;
xfs_extlen_t flen; xfs_extlen_t flen;
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_ag_vextent_small";
#endif
int i; int i;
if ((error = xfs_alloc_decrement(ccur, 0, &i))) if ((error = xfs_alloc_decrement(ccur, 0, &i)))
...@@ -1447,7 +1432,8 @@ xfs_alloc_ag_vextent_small( ...@@ -1447,7 +1432,8 @@ xfs_alloc_ag_vextent_small(
else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && else if (args->minlen == 1 && args->alignment == 1 && !args->isfl &&
(be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
> args->minleft)) { > args->minleft)) {
if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0);
if (error)
goto error0; goto error0;
if (fbno != NULLAGBLOCK) { if (fbno != NULLAGBLOCK) {
if (args->userdata) { if (args->userdata) {
...@@ -1515,9 +1501,6 @@ xfs_free_ag_extent( ...@@ -1515,9 +1501,6 @@ xfs_free_ag_extent(
xfs_btree_cur_t *bno_cur; /* cursor for by-block btree */ xfs_btree_cur_t *bno_cur; /* cursor for by-block btree */
xfs_btree_cur_t *cnt_cur; /* cursor for by-size btree */ xfs_btree_cur_t *cnt_cur; /* cursor for by-size btree */
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_free_ag_extent";
#endif
xfs_agblock_t gtbno; /* start of right neighbor block */ xfs_agblock_t gtbno; /* start of right neighbor block */
xfs_extlen_t gtlen; /* length of right neighbor block */ xfs_extlen_t gtlen; /* length of right neighbor block */
int haveleft; /* have a left neighbor block */ int haveleft; /* have a left neighbor block */
...@@ -1923,7 +1906,8 @@ xfs_alloc_fix_freelist( ...@@ -1923,7 +1906,8 @@ xfs_alloc_fix_freelist(
while (be32_to_cpu(agf->agf_flcount) > 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))) error = xfs_alloc_get_freelist(tp, agbp, &bno, 0);
if (error)
return error; return error;
if ((error = xfs_free_ag_extent(tp, agbp, args->agno, bno, 1, 1))) if ((error = xfs_free_ag_extent(tp, agbp, args->agno, bno, 1, 1)))
return error; return error;
...@@ -1973,8 +1957,9 @@ xfs_alloc_fix_freelist( ...@@ -1973,8 +1957,9 @@ xfs_alloc_fix_freelist(
* Put each allocated block on the list. * Put each allocated block on the list.
*/ */
for (bno = targs.agbno; bno < targs.agbno + targs.len; bno++) { for (bno = targs.agbno; bno < targs.agbno + targs.len; bno++) {
if ((error = xfs_alloc_put_freelist(tp, agbp, agflbp, error = xfs_alloc_put_freelist(tp, agbp,
bno))) agflbp, bno, 0);
if (error)
return error; return error;
} }
} }
...@@ -1991,16 +1976,15 @@ int /* error */ ...@@ -1991,16 +1976,15 @@ int /* error */
xfs_alloc_get_freelist( xfs_alloc_get_freelist(
xfs_trans_t *tp, /* transaction pointer */ xfs_trans_t *tp, /* transaction pointer */
xfs_buf_t *agbp, /* buffer containing the agf structure */ xfs_buf_t *agbp, /* buffer containing the agf structure */
xfs_agblock_t *bnop) /* block address retrieved from freelist */ xfs_agblock_t *bnop, /* block address retrieved from freelist */
int btreeblk) /* destination is a AGF btree */
{ {
xfs_agf_t *agf; /* a.g. freespace structure */ xfs_agf_t *agf; /* a.g. freespace structure */
xfs_agfl_t *agfl; /* a.g. freelist structure */ xfs_agfl_t *agfl; /* a.g. freelist structure */
xfs_buf_t *agflbp;/* buffer for a.g. freelist structure */ xfs_buf_t *agflbp;/* buffer for a.g. freelist structure */
xfs_agblock_t bno; /* block number returned */ xfs_agblock_t bno; /* block number returned */
int error; int error;
#ifdef XFS_ALLOC_TRACE int logflags;
static char fname[] = "xfs_alloc_get_freelist";
#endif
xfs_mount_t *mp; /* mount structure */ xfs_mount_t *mp; /* mount structure */
xfs_perag_t *pag; /* per allocation group data */ xfs_perag_t *pag; /* per allocation group data */
...@@ -2032,8 +2016,16 @@ xfs_alloc_get_freelist( ...@@ -2032,8 +2016,16 @@ xfs_alloc_get_freelist(
be32_add(&agf->agf_flcount, -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);
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT;
if (btreeblk) {
be32_add(&agf->agf_btreeblks, 1);
pag->pagf_btreeblks++;
logflags |= XFS_AGF_BTREEBLKS;
}
TRACE_MODAGF(NULL, agf, logflags);
xfs_alloc_log_agf(tp, agbp, logflags);
*bnop = bno; *bnop = bno;
/* /*
...@@ -2071,6 +2063,7 @@ xfs_alloc_log_agf( ...@@ -2071,6 +2063,7 @@ xfs_alloc_log_agf(
offsetof(xfs_agf_t, agf_flcount), offsetof(xfs_agf_t, agf_flcount),
offsetof(xfs_agf_t, agf_freeblks), offsetof(xfs_agf_t, agf_freeblks),
offsetof(xfs_agf_t, agf_longest), offsetof(xfs_agf_t, agf_longest),
offsetof(xfs_agf_t, agf_btreeblks),
sizeof(xfs_agf_t) sizeof(xfs_agf_t)
}; };
...@@ -2106,15 +2099,14 @@ xfs_alloc_put_freelist( ...@@ -2106,15 +2099,14 @@ xfs_alloc_put_freelist(
xfs_trans_t *tp, /* transaction pointer */ xfs_trans_t *tp, /* transaction pointer */
xfs_buf_t *agbp, /* buffer for a.g. freelist header */ xfs_buf_t *agbp, /* buffer for a.g. freelist header */
xfs_buf_t *agflbp,/* buffer for a.g. free block array */ xfs_buf_t *agflbp,/* buffer for a.g. free block array */
xfs_agblock_t bno) /* block being freed */ xfs_agblock_t bno, /* block being freed */
int btreeblk) /* block came from a AGF btree */
{ {
xfs_agf_t *agf; /* a.g. freespace structure */ xfs_agf_t *agf; /* a.g. freespace structure */
xfs_agfl_t *agfl; /* a.g. free block array */ xfs_agfl_t *agfl; /* a.g. free block array */
__be32 *blockp;/* pointer to array entry */ __be32 *blockp;/* pointer to array entry */
int error; int error;
#ifdef XFS_ALLOC_TRACE int logflags;
static char fname[] = "xfs_alloc_put_freelist";
#endif
xfs_mount_t *mp; /* mount structure */ xfs_mount_t *mp; /* mount structure */
xfs_perag_t *pag; /* per allocation group data */ xfs_perag_t *pag; /* per allocation group data */
...@@ -2132,11 +2124,22 @@ xfs_alloc_put_freelist( ...@@ -2132,11 +2124,22 @@ xfs_alloc_put_freelist(
be32_add(&agf->agf_flcount, 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++;
logflags = XFS_AGF_FLLAST | XFS_AGF_FLCOUNT;
if (btreeblk) {
be32_add(&agf->agf_btreeblks, -1);
pag->pagf_btreeblks--;
logflags |= XFS_AGF_BTREEBLKS;
}
TRACE_MODAGF(NULL, agf, logflags);
xfs_alloc_log_agf(tp, agbp, logflags);
ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)];
*blockp = cpu_to_be32(bno); *blockp = cpu_to_be32(bno);
TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); TRACE_MODAGF(NULL, agf, logflags);
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); xfs_alloc_log_agf(tp, agbp, logflags);
xfs_trans_log_buf(tp, agflbp, xfs_trans_log_buf(tp, agflbp,
(int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl), (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl),
(int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl + (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl +
...@@ -2196,6 +2199,7 @@ xfs_alloc_read_agf( ...@@ -2196,6 +2199,7 @@ 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 = be32_to_cpu(agf->agf_freeblks); pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks);
pag->pagf_btreeblks = be32_to_cpu(agf->agf_btreeblks);
pag->pagf_flcount = be32_to_cpu(agf->agf_flcount); pag->pagf_flcount = be32_to_cpu(agf->agf_flcount);
pag->pagf_longest = be32_to_cpu(agf->agf_longest); pag->pagf_longest = be32_to_cpu(agf->agf_longest);
pag->pagf_levels[XFS_BTNUM_BNOi] = pag->pagf_levels[XFS_BTNUM_BNOi] =
...@@ -2235,9 +2239,6 @@ xfs_alloc_vextent( ...@@ -2235,9 +2239,6 @@ xfs_alloc_vextent(
xfs_agblock_t agsize; /* allocation group size */ xfs_agblock_t agsize; /* allocation group size */
int error; int error;
int flags; /* XFS_ALLOC_FLAG_... locking flags */ int flags; /* XFS_ALLOC_FLAG_... locking flags */
#ifdef XFS_ALLOC_TRACE
static char fname[] = "xfs_alloc_vextent";
#endif
xfs_extlen_t minleft;/* minimum left value, temp copy */ xfs_extlen_t minleft;/* minimum left value, temp copy */
xfs_mount_t *mp; /* mount structure pointer */ xfs_mount_t *mp; /* mount structure pointer */
xfs_agnumber_t sagno; /* starting allocation group number */ xfs_agnumber_t sagno; /* starting allocation group number */
......
...@@ -136,7 +136,8 @@ int /* error */ ...@@ -136,7 +136,8 @@ int /* error */
xfs_alloc_get_freelist( xfs_alloc_get_freelist(
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
struct xfs_buf *agbp, /* buffer containing the agf structure */ struct xfs_buf *agbp, /* buffer containing the agf structure */
xfs_agblock_t *bnop); /* block address retrieved from freelist */ xfs_agblock_t *bnop, /* block address retrieved from freelist */
int btreeblk); /* destination is a AGF btree */
/* /*
* Log the given fields from the agf structure. * Log the given fields from the agf structure.
...@@ -165,7 +166,8 @@ xfs_alloc_put_freelist( ...@@ -165,7 +166,8 @@ xfs_alloc_put_freelist(
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
struct xfs_buf *agbp, /* buffer for a.g. freelist header */ struct xfs_buf *agbp, /* buffer for a.g. freelist header */
struct xfs_buf *agflbp,/* buffer for a.g. free block array */ struct xfs_buf *agflbp,/* buffer for a.g. free block array */
xfs_agblock_t bno); /* block being freed */ xfs_agblock_t bno, /* block being freed */
int btreeblk); /* owner was a AGF btree */
/* /*
* Read in the allocation group header (free/alloc section). * Read in the allocation group header (free/alloc section).
......
...@@ -226,8 +226,9 @@ xfs_alloc_delrec( ...@@ -226,8 +226,9 @@ xfs_alloc_delrec(
/* /*
* Put this buffer/block on the ag's freelist. * Put this buffer/block on the ag's freelist.
*/ */
if ((error = xfs_alloc_put_freelist(cur->bc_tp, error = xfs_alloc_put_freelist(cur->bc_tp,
cur->bc_private.a.agbp, NULL, bno))) cur->bc_private.a.agbp, NULL, bno, 1);
if (error)
return error; return error;
/* /*
* Since blocks move to the free list without the * Since blocks move to the free list without the
...@@ -549,8 +550,9 @@ xfs_alloc_delrec( ...@@ -549,8 +550,9 @@ xfs_alloc_delrec(
/* /*
* Free the deleting block by putting it on the freelist. * Free the deleting block by putting it on the freelist.
*/ */
if ((error = xfs_alloc_put_freelist(cur->bc_tp, cur->bc_private.a.agbp, error = xfs_alloc_put_freelist(cur->bc_tp,
NULL, rbno))) cur->bc_private.a.agbp, NULL, rbno, 1);
if (error)
return error; return error;
/* /*
* Since blocks move to the free list without the coordination * Since blocks move to the free list without the coordination
...@@ -1320,8 +1322,9 @@ xfs_alloc_newroot( ...@@ -1320,8 +1322,9 @@ xfs_alloc_newroot(
/* /*
* Get a buffer from the freelist blocks, for the new root. * Get a buffer from the freelist blocks, for the new root.
*/ */
if ((error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp, error = xfs_alloc_get_freelist(cur->bc_tp,
&nbno))) cur->bc_private.a.agbp, &nbno, 1);
if (error)
return error; return error;
/* /*
* None available, we fail. * None available, we fail.
...@@ -1604,8 +1607,9 @@ xfs_alloc_split( ...@@ -1604,8 +1607,9 @@ xfs_alloc_split(
* Allocate the new block from the freelist. * Allocate the new block from the freelist.
* If we can't do it, we're toast. Give up. * If we can't do it, we're toast. Give up.
*/ */
if ((error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp, error = xfs_alloc_get_freelist(cur->bc_tp,
&rbno))) cur->bc_private.a.agbp, &rbno, 1);
if (error)
return error; return error;
if (rbno == NULLAGBLOCK) { if (rbno == NULLAGBLOCK) {
*stat = 0; *stat = 0;
......
...@@ -65,44 +65,6 @@ static const char xfs_highbit[256] = { ...@@ -65,44 +65,6 @@ static const char xfs_highbit[256] = {
}; };
#endif #endif
/*
* Count of bits set in byte, 0..8.
*/
static const char xfs_countbit[256] = {
0, 1, 1, 2, 1, 2, 2, 3, /* 00 .. 07 */
1, 2, 2, 3, 2, 3, 3, 4, /* 08 .. 0f */
1, 2, 2, 3, 2, 3, 3, 4, /* 10 .. 17 */
2, 3, 3, 4, 3, 4, 4, 5, /* 18 .. 1f */
1, 2, 2, 3, 2, 3, 3, 4, /* 20 .. 27 */
2, 3, 3, 4, 3, 4, 4, 5, /* 28 .. 2f */
2, 3, 3, 4, 3, 4, 4, 5, /* 30 .. 37 */
3, 4, 4, 5, 4, 5, 5, 6, /* 38 .. 3f */
1, 2, 2, 3, 2, 3, 3, 4, /* 40 .. 47 */
2, 3, 3, 4, 3, 4, 4, 5, /* 48 .. 4f */
2, 3, 3, 4, 3, 4, 4, 5, /* 50 .. 57 */
3, 4, 4, 5, 4, 5, 5, 6, /* 58 .. 5f */
2, 3, 3, 4, 3, 4, 4, 5, /* 60 .. 67 */
3, 4, 4, 5, 4, 5, 5, 6, /* 68 .. 6f */
3, 4, 4, 5, 4, 5, 5, 6, /* 70 .. 77 */
4, 5, 5, 6, 5, 6, 6, 7, /* 78 .. 7f */
1, 2, 2, 3, 2, 3, 3, 4, /* 80 .. 87 */
2, 3, 3, 4, 3, 4, 4, 5, /* 88 .. 8f */
2, 3, 3, 4, 3, 4, 4, 5, /* 90 .. 97 */
3, 4, 4, 5, 4, 5, 5, 6, /* 98 .. 9f */
2, 3, 3, 4, 3, 4, 4, 5, /* a0 .. a7 */
3, 4, 4, 5, 4, 5, 5, 6, /* a8 .. af */
3, 4, 4, 5, 4, 5, 5, 6, /* b0 .. b7 */
4, 5, 5, 6, 5, 6, 6, 7, /* b8 .. bf */
2, 3, 3, 4, 3, 4, 4, 5, /* c0 .. c7 */
3, 4, 4, 5, 4, 5, 5, 6, /* c8 .. cf */
3, 4, 4, 5, 4, 5, 5, 6, /* d0 .. d7 */
4, 5, 5, 6, 5, 6, 6, 7, /* d8 .. df */
3, 4, 4, 5, 4, 5, 5, 6, /* e0 .. e7 */
4, 5, 5, 6, 5, 6, 6, 7, /* e8 .. ef */
4, 5, 5, 6, 5, 6, 6, 7, /* f0 .. f7 */
5, 6, 6, 7, 6, 7, 7, 8, /* f8 .. ff */
};
/* /*
* xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set. * xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set.
*/ */
...@@ -167,56 +129,21 @@ xfs_highbit64( ...@@ -167,56 +129,21 @@ xfs_highbit64(
/* /*
* Count the number of bits set in the bitmap starting with bit * Return whether bitmap is empty.
* start_bit. Size is the size of the bitmap in words. * Size is number of words in the bitmap, which is padded to word boundary
* * Returns 1 for empty, 0 for non-empty.
* Do the counting by mapping a byte value to the number of set
* bits for that value using the xfs_countbit array, i.e.
* xfs_countbit[0] == 0, xfs_countbit[1] == 1, xfs_countbit[2] == 1,
* xfs_countbit[3] == 2, etc.
*/ */
int int
xfs_count_bits(uint *map, uint size, uint start_bit) xfs_bitmap_empty(uint *map, uint size)
{ {
register int bits; uint i;
register unsigned char *bytep; uint ret = 0;
register unsigned char *end_map;
int byte_bit;
bits = 0;
end_map = (char*)(map + size);
bytep = (char*)(map + (start_bit & ~0x7));
byte_bit = start_bit & 0x7;
/*
* If the caller fell off the end of the map, return 0.
*/
if (bytep >= end_map) {
return (0);
}
/*
* If start_bit is not byte aligned, then process the
* first byte separately.
*/
if (byte_bit != 0) {
/*
* Shift off the bits we don't want to look at,
* before indexing into xfs_countbit.
*/
bits += xfs_countbit[(*bytep >> byte_bit)];
bytep++;
}
/* for (i = 0; i < size; i++) {
* Count the bits in each byte until the end of the bitmap. ret |= map[i];
*/
while (bytep < end_map) {
bits += xfs_countbit[*bytep];
bytep++;
} }
return (bits); return (ret == 0);
} }
/* /*
......
...@@ -55,8 +55,8 @@ extern int xfs_lowbit64(__uint64_t v); ...@@ -55,8 +55,8 @@ extern int xfs_lowbit64(__uint64_t v);
/* Get high bit set out of 64-bit argument, -1 if none set */ /* Get high bit set out of 64-bit argument, -1 if none set */
extern int xfs_highbit64(__uint64_t); extern int xfs_highbit64(__uint64_t);
/* Count set bits in map starting with start_bit */ /* Return whether bitmap is empty (1 == empty) */
extern int xfs_count_bits(uint *map, uint size, uint start_bit); extern int xfs_bitmap_empty(uint *map, uint size);
/* Count continuous one bits in map starting with start_bit */ /* Count continuous one bits in map starting with start_bit */
extern int xfs_contig_bits(uint *map, uint size, uint start_bit); extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
......
此差异已折叠。
...@@ -144,12 +144,14 @@ extern ktrace_t *xfs_bmap_trace_buf; ...@@ -144,12 +144,14 @@ extern ktrace_t *xfs_bmap_trace_buf;
*/ */
void void
xfs_bmap_trace_exlist( xfs_bmap_trace_exlist(
char *fname, /* function name */ const char *fname, /* function name */
struct xfs_inode *ip, /* incore inode pointer */ struct xfs_inode *ip, /* incore inode pointer */
xfs_extnum_t cnt, /* count of entries in list */ xfs_extnum_t cnt, /* count of entries in list */
int whichfork); /* data or attr fork */ int whichfork); /* data or attr fork */
#define XFS_BMAP_TRACE_EXLIST(ip,c,w) \
xfs_bmap_trace_exlist(__FUNCTION__,ip,c,w)
#else #else
#define xfs_bmap_trace_exlist(f,ip,c,w) #define XFS_BMAP_TRACE_EXLIST(ip,c,w)
#endif #endif
/* /*
......
...@@ -76,7 +76,7 @@ static char EXIT[] = "exit"; ...@@ -76,7 +76,7 @@ static char EXIT[] = "exit";
*/ */
STATIC void STATIC void
xfs_bmbt_trace_enter( xfs_bmbt_trace_enter(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
char *s, char *s,
int type, int type,
...@@ -117,7 +117,7 @@ xfs_bmbt_trace_enter( ...@@ -117,7 +117,7 @@ xfs_bmbt_trace_enter(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argbi( xfs_bmbt_trace_argbi(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
xfs_buf_t *b, xfs_buf_t *b,
int i, int i,
...@@ -134,7 +134,7 @@ xfs_bmbt_trace_argbi( ...@@ -134,7 +134,7 @@ xfs_bmbt_trace_argbi(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argbii( xfs_bmbt_trace_argbii(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
xfs_buf_t *b, xfs_buf_t *b,
int i0, int i0,
...@@ -153,7 +153,7 @@ xfs_bmbt_trace_argbii( ...@@ -153,7 +153,7 @@ xfs_bmbt_trace_argbii(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argfffi( xfs_bmbt_trace_argfffi(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
xfs_dfiloff_t o, xfs_dfiloff_t o,
xfs_dfsbno_t b, xfs_dfsbno_t b,
...@@ -172,7 +172,7 @@ xfs_bmbt_trace_argfffi( ...@@ -172,7 +172,7 @@ xfs_bmbt_trace_argfffi(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argi( xfs_bmbt_trace_argi(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
int i, int i,
int line) int line)
...@@ -188,7 +188,7 @@ xfs_bmbt_trace_argi( ...@@ -188,7 +188,7 @@ xfs_bmbt_trace_argi(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argifk( xfs_bmbt_trace_argifk(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
int i, int i,
xfs_fsblock_t f, xfs_fsblock_t f,
...@@ -206,7 +206,7 @@ xfs_bmbt_trace_argifk( ...@@ -206,7 +206,7 @@ xfs_bmbt_trace_argifk(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argifr( xfs_bmbt_trace_argifr(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
int i, int i,
xfs_fsblock_t f, xfs_fsblock_t f,
...@@ -235,7 +235,7 @@ xfs_bmbt_trace_argifr( ...@@ -235,7 +235,7 @@ xfs_bmbt_trace_argifr(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_argik( xfs_bmbt_trace_argik(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
int i, int i,
xfs_bmbt_key_t *k, xfs_bmbt_key_t *k,
...@@ -255,7 +255,7 @@ xfs_bmbt_trace_argik( ...@@ -255,7 +255,7 @@ xfs_bmbt_trace_argik(
*/ */
STATIC void STATIC void
xfs_bmbt_trace_cursor( xfs_bmbt_trace_cursor(
char *func, const char *func,
xfs_btree_cur_t *cur, xfs_btree_cur_t *cur,
char *s, char *s,
int line) int line)
...@@ -274,21 +274,21 @@ xfs_bmbt_trace_cursor( ...@@ -274,21 +274,21 @@ xfs_bmbt_trace_cursor(
} }
#define XFS_BMBT_TRACE_ARGBI(c,b,i) \ #define XFS_BMBT_TRACE_ARGBI(c,b,i) \
xfs_bmbt_trace_argbi(fname, c, b, i, __LINE__) xfs_bmbt_trace_argbi(__FUNCTION__, c, b, i, __LINE__)
#define XFS_BMBT_TRACE_ARGBII(c,b,i,j) \ #define XFS_BMBT_TRACE_ARGBII(c,b,i,j) \
xfs_bmbt_trace_argbii(fname, c, b, i, j, __LINE__) xfs_bmbt_trace_argbii(__FUNCTION__, c, b, i, j, __LINE__)
#define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) \ #define XFS_BMBT_TRACE_ARGFFFI(c,o,b,i,j) \
xfs_bmbt_trace_argfffi(fname, c, o, b, i, j, __LINE__) xfs_bmbt_trace_argfffi(__FUNCTION__, c, o, b, i, j, __LINE__)
#define XFS_BMBT_TRACE_ARGI(c,i) \ #define XFS_BMBT_TRACE_ARGI(c,i) \
xfs_bmbt_trace_argi(fname, c, i, __LINE__) xfs_bmbt_trace_argi(__FUNCTION__, c, i, __LINE__)
#define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \ #define XFS_BMBT_TRACE_ARGIFK(c,i,f,s) \
xfs_bmbt_trace_argifk(fname, c, i, f, s, __LINE__) xfs_bmbt_trace_argifk(__FUNCTION__, c, i, f, s, __LINE__)
#define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \ #define XFS_BMBT_TRACE_ARGIFR(c,i,f,r) \
xfs_bmbt_trace_argifr(fname, c, i, f, r, __LINE__) xfs_bmbt_trace_argifr(__FUNCTION__, c, i, f, r, __LINE__)
#define XFS_BMBT_TRACE_ARGIK(c,i,k) \ #define XFS_BMBT_TRACE_ARGIK(c,i,k) \
xfs_bmbt_trace_argik(fname, c, i, k, __LINE__) xfs_bmbt_trace_argik(__FUNCTION__, c, i, k, __LINE__)
#define XFS_BMBT_TRACE_CURSOR(c,s) \ #define XFS_BMBT_TRACE_CURSOR(c,s) \
xfs_bmbt_trace_cursor(fname, c, s, __LINE__) xfs_bmbt_trace_cursor(__FUNCTION__, c, s, __LINE__)
#else #else
#define XFS_BMBT_TRACE_ARGBI(c,b,i) #define XFS_BMBT_TRACE_ARGBI(c,b,i)
#define XFS_BMBT_TRACE_ARGBII(c,b,i,j) #define XFS_BMBT_TRACE_ARGBII(c,b,i,j)
...@@ -318,9 +318,6 @@ xfs_bmbt_delrec( ...@@ -318,9 +318,6 @@ xfs_bmbt_delrec(
xfs_fsblock_t bno; /* fs-relative block number */ xfs_fsblock_t bno; /* fs-relative block number */
xfs_buf_t *bp; /* buffer for block */ xfs_buf_t *bp; /* buffer for block */
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_delrec";
#endif
int i; /* loop counter */ int i; /* loop counter */
int j; /* temp state */ int j; /* temp state */
xfs_bmbt_key_t key; /* bmap btree key */ xfs_bmbt_key_t key; /* bmap btree key */
...@@ -694,9 +691,6 @@ xfs_bmbt_insrec( ...@@ -694,9 +691,6 @@ xfs_bmbt_insrec(
xfs_bmbt_block_t *block; /* bmap btree block */ xfs_bmbt_block_t *block; /* bmap btree block */
xfs_buf_t *bp; /* buffer for block */ xfs_buf_t *bp; /* buffer for block */
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_insrec";
#endif
int i; /* loop index */ int i; /* loop index */
xfs_bmbt_key_t key; /* bmap btree key */ xfs_bmbt_key_t key; /* bmap btree key */
xfs_bmbt_key_t *kp=NULL; /* pointer to bmap btree key */ xfs_bmbt_key_t *kp=NULL; /* pointer to bmap btree key */
...@@ -880,9 +874,6 @@ xfs_bmbt_killroot( ...@@ -880,9 +874,6 @@ xfs_bmbt_killroot(
xfs_bmbt_ptr_t *cpp; xfs_bmbt_ptr_t *cpp;
#ifdef DEBUG #ifdef DEBUG
int error; int error;
#endif
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_killroot";
#endif #endif
int i; int i;
xfs_bmbt_key_t *kp; xfs_bmbt_key_t *kp;
...@@ -973,9 +964,6 @@ xfs_bmbt_log_keys( ...@@ -973,9 +964,6 @@ xfs_bmbt_log_keys(
int kfirst, int kfirst,
int klast) int klast)
{ {
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_log_keys";
#endif
xfs_trans_t *tp; xfs_trans_t *tp;
XFS_BMBT_TRACE_CURSOR(cur, ENTRY); XFS_BMBT_TRACE_CURSOR(cur, ENTRY);
...@@ -1012,9 +1000,6 @@ xfs_bmbt_log_ptrs( ...@@ -1012,9 +1000,6 @@ xfs_bmbt_log_ptrs(
int pfirst, int pfirst,
int plast) int plast)
{ {
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_log_ptrs";
#endif
xfs_trans_t *tp; xfs_trans_t *tp;
XFS_BMBT_TRACE_CURSOR(cur, ENTRY); XFS_BMBT_TRACE_CURSOR(cur, ENTRY);
...@@ -1055,9 +1040,6 @@ xfs_bmbt_lookup( ...@@ -1055,9 +1040,6 @@ xfs_bmbt_lookup(
xfs_daddr_t d; xfs_daddr_t d;
xfs_sfiloff_t diff; xfs_sfiloff_t diff;
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_lookup";
#endif
xfs_fsblock_t fsbno=0; xfs_fsblock_t fsbno=0;
int high; int high;
int i; int i;
...@@ -1195,9 +1177,6 @@ xfs_bmbt_lshift( ...@@ -1195,9 +1177,6 @@ xfs_bmbt_lshift(
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_lshift";
#endif
#ifdef DEBUG #ifdef DEBUG
int i; /* loop counter */ int i; /* loop counter */
#endif #endif
...@@ -1331,9 +1310,6 @@ xfs_bmbt_rshift( ...@@ -1331,9 +1310,6 @@ xfs_bmbt_rshift(
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_rshift";
#endif
int i; /* loop counter */ int i; /* loop counter */
xfs_bmbt_key_t key; /* bmap btree key */ xfs_bmbt_key_t key; /* bmap btree key */
xfs_buf_t *lbp; /* left buffer pointer */ xfs_buf_t *lbp; /* left buffer pointer */
...@@ -1492,9 +1468,6 @@ xfs_bmbt_split( ...@@ -1492,9 +1468,6 @@ xfs_bmbt_split(
{ {
xfs_alloc_arg_t args; /* block allocation args */ xfs_alloc_arg_t args; /* block allocation args */
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_split";
#endif
int i; /* loop counter */ int i; /* loop counter */
xfs_fsblock_t lbno; /* left sibling block number */ xfs_fsblock_t lbno; /* left sibling block number */
xfs_buf_t *lbp; /* left buffer pointer */ xfs_buf_t *lbp; /* left buffer pointer */
...@@ -1640,9 +1613,6 @@ xfs_bmbt_updkey( ...@@ -1640,9 +1613,6 @@ xfs_bmbt_updkey(
xfs_buf_t *bp; xfs_buf_t *bp;
#ifdef DEBUG #ifdef DEBUG
int error; int error;
#endif
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_updkey";
#endif #endif
xfs_bmbt_key_t *kp; xfs_bmbt_key_t *kp;
int ptr; int ptr;
...@@ -1712,9 +1682,6 @@ xfs_bmbt_decrement( ...@@ -1712,9 +1682,6 @@ xfs_bmbt_decrement(
xfs_bmbt_block_t *block; xfs_bmbt_block_t *block;
xfs_buf_t *bp; xfs_buf_t *bp;
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_decrement";
#endif
xfs_fsblock_t fsbno; xfs_fsblock_t fsbno;
int lev; int lev;
xfs_mount_t *mp; xfs_mount_t *mp;
...@@ -1785,9 +1752,6 @@ xfs_bmbt_delete( ...@@ -1785,9 +1752,6 @@ xfs_bmbt_delete(
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_delete";
#endif
int i; int i;
int level; int level;
...@@ -2000,9 +1964,6 @@ xfs_bmbt_increment( ...@@ -2000,9 +1964,6 @@ xfs_bmbt_increment(
xfs_bmbt_block_t *block; xfs_bmbt_block_t *block;
xfs_buf_t *bp; xfs_buf_t *bp;
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_increment";
#endif
xfs_fsblock_t fsbno; xfs_fsblock_t fsbno;
int lev; int lev;
xfs_mount_t *mp; xfs_mount_t *mp;
...@@ -2080,9 +2041,6 @@ xfs_bmbt_insert( ...@@ -2080,9 +2041,6 @@ xfs_bmbt_insert(
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; /* error return value */ int error; /* error return value */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_insert";
#endif
int i; int i;
int level; int level;
xfs_fsblock_t nbno; xfs_fsblock_t nbno;
...@@ -2142,9 +2100,6 @@ xfs_bmbt_log_block( ...@@ -2142,9 +2100,6 @@ xfs_bmbt_log_block(
int fields) int fields)
{ {
int first; int first;
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_log_block";
#endif
int last; int last;
xfs_trans_t *tp; xfs_trans_t *tp;
static const short offsets[] = { static const short offsets[] = {
...@@ -2181,9 +2136,6 @@ xfs_bmbt_log_recs( ...@@ -2181,9 +2136,6 @@ xfs_bmbt_log_recs(
{ {
xfs_bmbt_block_t *block; xfs_bmbt_block_t *block;
int first; int first;
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_log_recs";
#endif
int last; int last;
xfs_bmbt_rec_t *rp; xfs_bmbt_rec_t *rp;
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -2245,9 +2197,6 @@ xfs_bmbt_newroot( ...@@ -2245,9 +2197,6 @@ xfs_bmbt_newroot(
xfs_bmbt_key_t *ckp; /* child key pointer */ xfs_bmbt_key_t *ckp; /* child key pointer */
xfs_bmbt_ptr_t *cpp; /* child ptr pointer */ xfs_bmbt_ptr_t *cpp; /* child ptr pointer */
int error; /* error return code */ int error; /* error return code */
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_newroot";
#endif
#ifdef DEBUG #ifdef DEBUG
int i; /* loop counter */ int i; /* loop counter */
#endif #endif
...@@ -2630,9 +2579,6 @@ xfs_bmbt_update( ...@@ -2630,9 +2579,6 @@ xfs_bmbt_update(
xfs_bmbt_block_t *block; xfs_bmbt_block_t *block;
xfs_buf_t *bp; xfs_buf_t *bp;
int error; int error;
#ifdef XFS_BMBT_TRACE
static char fname[] = "xfs_bmbt_update";
#endif
xfs_bmbt_key_t key; xfs_bmbt_key_t key;
int ptr; int ptr;
xfs_bmbt_rec_t *rp; xfs_bmbt_rec_t *rp;
......
...@@ -444,30 +444,14 @@ xfs_btree_setbuf( ...@@ -444,30 +444,14 @@ 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.
*/ */
#define XFS_EXTLEN_MIN(a,b) \ #define XFS_EXTLEN_MIN(a,b) min_t(xfs_extlen_t, (a), (b))
((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ #define XFS_EXTLEN_MAX(a,b) max_t(xfs_extlen_t, (a), (b))
(xfs_extlen_t)(a) : (xfs_extlen_t)(b)) #define XFS_AGBLOCK_MIN(a,b) min_t(xfs_agblock_t, (a), (b))
#define XFS_EXTLEN_MAX(a,b) \ #define XFS_AGBLOCK_MAX(a,b) max_t(xfs_agblock_t, (a), (b))
((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ #define XFS_FILEOFF_MIN(a,b) min_t(xfs_fileoff_t, (a), (b))
(xfs_extlen_t)(a) : (xfs_extlen_t)(b)) #define XFS_FILEOFF_MAX(a,b) max_t(xfs_fileoff_t, (a), (b))
#define XFS_AGBLOCK_MIN(a,b) \ #define XFS_FILBLKS_MIN(a,b) min_t(xfs_filblks_t, (a), (b))
((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ #define XFS_FILBLKS_MAX(a,b) max_t(xfs_filblks_t, (a), (b))
(xfs_agblock_t)(a) : (xfs_agblock_t)(b))
#define XFS_AGBLOCK_MAX(a,b) \
((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \
(xfs_agblock_t)(a) : (xfs_agblock_t)(b))
#define XFS_FILEOFF_MIN(a,b) \
((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \
(xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
#define XFS_FILEOFF_MAX(a,b) \
((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \
(xfs_fileoff_t)(a) : (xfs_fileoff_t)(b))
#define XFS_FILBLKS_MIN(a,b) \
((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \
(xfs_filblks_t)(a) : (xfs_filblks_t)(b))
#define XFS_FILBLKS_MAX(a,b) \
((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \
(xfs_filblks_t)(a) : (xfs_filblks_t)(b))
#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 && \
......
...@@ -580,8 +580,8 @@ xfs_buf_item_unlock( ...@@ -580,8 +580,8 @@ xfs_buf_item_unlock(
* If the buf item isn't tracking any data, free it. * If the buf item isn't tracking any data, free it.
* Otherwise, if XFS_BLI_HOLD is set clear it. * Otherwise, if XFS_BLI_HOLD is set clear it.
*/ */
if (xfs_count_bits(bip->bli_format.blf_data_map, if (xfs_bitmap_empty(bip->bli_format.blf_data_map,
bip->bli_format.blf_map_size, 0) == 0) { bip->bli_format.blf_map_size)) {
xfs_buf_item_relse(bp); xfs_buf_item_relse(bp);
} else if (hold) { } else if (hold) {
bip->bli_flags &= ~XFS_BLI_HOLD; bip->bli_flags &= ~XFS_BLI_HOLD;
......
...@@ -99,5 +99,7 @@ struct xfs_mount_args { ...@@ -99,5 +99,7 @@ struct xfs_mount_args {
*/ */
#define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred
* I/O size in stat(2) */ * I/O size in stat(2) */
#define XFSMNT2_FILESTREAMS 0x00000002 /* enable the filestreams
* allocator */
#endif /* __XFS_CLNT_H__ */ #endif /* __XFS_CLNT_H__ */
...@@ -257,6 +257,7 @@ typedef enum xfs_dinode_fmt ...@@ -257,6 +257,7 @@ typedef enum xfs_dinode_fmt
#define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */
#define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
#define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
#define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
#define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
#define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
#define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
...@@ -271,12 +272,13 @@ typedef enum xfs_dinode_fmt ...@@ -271,12 +272,13 @@ typedef enum xfs_dinode_fmt
#define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT)
#define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
#define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
#define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
#define XFS_DIFLAG_ANY \ #define XFS_DIFLAG_ANY \
(XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG) XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
#endif /* __XFS_DINODE_H__ */ #endif /* __XFS_DINODE_H__ */
...@@ -55,9 +55,9 @@ xfs_dir_mount( ...@@ -55,9 +55,9 @@ xfs_dir_mount(
XFS_MAX_BLOCKSIZE); XFS_MAX_BLOCKSIZE);
mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog); mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog);
mp->m_dirblkfsbs = 1 << mp->m_sb.sb_dirblklog; mp->m_dirblkfsbs = 1 << mp->m_sb.sb_dirblklog;
mp->m_dirdatablk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_DATA_FIRSTDB(mp)); mp->m_dirdatablk = xfs_dir2_db_to_da(mp, XFS_DIR2_DATA_FIRSTDB(mp));
mp->m_dirleafblk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_LEAF_FIRSTDB(mp)); mp->m_dirleafblk = xfs_dir2_db_to_da(mp, XFS_DIR2_LEAF_FIRSTDB(mp));
mp->m_dirfreeblk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_FREE_FIRSTDB(mp)); mp->m_dirfreeblk = xfs_dir2_db_to_da(mp, XFS_DIR2_FREE_FIRSTDB(mp));
mp->m_attr_node_ents = mp->m_attr_node_ents =
(mp->m_sb.sb_blocksize - (uint)sizeof(xfs_da_node_hdr_t)) / (mp->m_sb.sb_blocksize - (uint)sizeof(xfs_da_node_hdr_t)) /
(uint)sizeof(xfs_da_node_entry_t); (uint)sizeof(xfs_da_node_entry_t);
...@@ -554,7 +554,7 @@ xfs_dir2_grow_inode( ...@@ -554,7 +554,7 @@ xfs_dir2_grow_inode(
*/ */
if (mapp != &map) if (mapp != &map)
kmem_free(mapp, sizeof(*mapp) * count); kmem_free(mapp, sizeof(*mapp) * count);
*dbp = XFS_DIR2_DA_TO_DB(mp, (xfs_dablk_t)bno); *dbp = xfs_dir2_da_to_db(mp, (xfs_dablk_t)bno);
/* /*
* Update file's size if this is the data space and it grew. * Update file's size if this is the data space and it grew.
*/ */
...@@ -706,7 +706,7 @@ xfs_dir2_shrink_inode( ...@@ -706,7 +706,7 @@ xfs_dir2_shrink_inode(
dp = args->dp; dp = args->dp;
mp = dp->i_mount; mp = dp->i_mount;
tp = args->trans; tp = args->trans;
da = XFS_DIR2_DB_TO_DA(mp, db); da = xfs_dir2_db_to_da(mp, db);
/* /*
* Unmap the fsblock(s). * Unmap the fsblock(s).
*/ */
...@@ -742,7 +742,7 @@ xfs_dir2_shrink_inode( ...@@ -742,7 +742,7 @@ xfs_dir2_shrink_inode(
/* /*
* If the block isn't the last one in the directory, we're done. * If the block isn't the last one in the directory, we're done.
*/ */
if (dp->i_d.di_size > XFS_DIR2_DB_OFF_TO_BYTE(mp, db + 1, 0)) if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(mp, db + 1, 0))
return 0; return 0;
bno = da; bno = da;
if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) { if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
......
...@@ -115,13 +115,13 @@ xfs_dir2_block_addname( ...@@ -115,13 +115,13 @@ xfs_dir2_block_addname(
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
len = XFS_DIR2_DATA_ENTSIZE(args->namelen); len = xfs_dir2_data_entsize(args->namelen);
/* /*
* Set up pointers to parts of the block. * Set up pointers to parts of the block.
*/ */
bf = block->hdr.bestfree; bf = block->hdr.bestfree;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* No stale entries? Need space for entry and new leaf. * No stale entries? Need space for entry and new leaf.
*/ */
...@@ -396,7 +396,7 @@ xfs_dir2_block_addname( ...@@ -396,7 +396,7 @@ xfs_dir2_block_addname(
* Fill in the leaf entry. * Fill in the leaf entry.
*/ */
blp[mid].hashval = cpu_to_be32(args->hashval); blp[mid].hashval = cpu_to_be32(args->hashval);
blp[mid].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, blp[mid].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
(char *)dep - (char *)block)); (char *)dep - (char *)block));
xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh);
/* /*
...@@ -411,7 +411,7 @@ xfs_dir2_block_addname( ...@@ -411,7 +411,7 @@ xfs_dir2_block_addname(
dep->inumber = cpu_to_be64(args->inumber); dep->inumber = cpu_to_be64(args->inumber);
dep->namelen = args->namelen; dep->namelen = args->namelen;
memcpy(dep->name, args->name, args->namelen); memcpy(dep->name, args->name, args->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)block); *tagp = cpu_to_be16((char *)dep - (char *)block);
/* /*
* Clean up the bestfree array and log the header, tail, and entry. * Clean up the bestfree array and log the header, tail, and entry.
...@@ -455,7 +455,7 @@ xfs_dir2_block_getdents( ...@@ -455,7 +455,7 @@ xfs_dir2_block_getdents(
/* /*
* If the block number in the offset is out of range, we're done. * If the block number in the offset is out of range, we're done.
*/ */
if (XFS_DIR2_DATAPTR_TO_DB(mp, uio->uio_offset) > mp->m_dirdatablk) { if (xfs_dir2_dataptr_to_db(mp, uio->uio_offset) > mp->m_dirdatablk) {
*eofp = 1; *eofp = 1;
return 0; return 0;
} }
...@@ -471,15 +471,15 @@ xfs_dir2_block_getdents( ...@@ -471,15 +471,15 @@ xfs_dir2_block_getdents(
* Extract the byte offset we start at from the seek pointer. * Extract the byte offset we start at from the seek pointer.
* We'll skip entries before this. * We'll skip entries before this.
*/ */
wantoff = XFS_DIR2_DATAPTR_TO_OFF(mp, uio->uio_offset); wantoff = xfs_dir2_dataptr_to_off(mp, uio->uio_offset);
block = bp->data; block = bp->data;
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
/* /*
* Set up values for the loop. * Set up values for the loop.
*/ */
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
ptr = (char *)block->u; ptr = (char *)block->u;
endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
p.dbp = dbp; p.dbp = dbp;
p.put = put; p.put = put;
p.uio = uio; p.uio = uio;
...@@ -502,7 +502,7 @@ xfs_dir2_block_getdents( ...@@ -502,7 +502,7 @@ xfs_dir2_block_getdents(
/* /*
* Bump pointer for the next iteration. * Bump pointer for the next iteration.
*/ */
ptr += XFS_DIR2_DATA_ENTSIZE(dep->namelen); ptr += xfs_dir2_data_entsize(dep->namelen);
/* /*
* The entry is before the desired starting point, skip it. * The entry is before the desired starting point, skip it.
*/ */
...@@ -513,7 +513,7 @@ xfs_dir2_block_getdents( ...@@ -513,7 +513,7 @@ xfs_dir2_block_getdents(
*/ */
p.namelen = dep->namelen; p.namelen = dep->namelen;
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, p.cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
ptr - (char *)block); ptr - (char *)block);
p.ino = be64_to_cpu(dep->inumber); p.ino = be64_to_cpu(dep->inumber);
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
...@@ -531,7 +531,7 @@ xfs_dir2_block_getdents( ...@@ -531,7 +531,7 @@ xfs_dir2_block_getdents(
*/ */
if (!p.done) { if (!p.done) {
uio->uio_offset = uio->uio_offset =
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
(char *)dep - (char *)block); (char *)dep - (char *)block);
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
return error; return error;
...@@ -545,7 +545,7 @@ xfs_dir2_block_getdents( ...@@ -545,7 +545,7 @@ xfs_dir2_block_getdents(
*eofp = 1; *eofp = 1;
uio->uio_offset = uio->uio_offset =
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk + 1, 0); xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0);
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
...@@ -569,8 +569,8 @@ xfs_dir2_block_log_leaf( ...@@ -569,8 +569,8 @@ xfs_dir2_block_log_leaf(
mp = tp->t_mountp; mp = tp->t_mountp;
block = bp->data; block = bp->data;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)block), xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)block),
(uint)((char *)&blp[last + 1] - (char *)block - 1)); (uint)((char *)&blp[last + 1] - (char *)block - 1));
} }
...@@ -589,7 +589,7 @@ xfs_dir2_block_log_tail( ...@@ -589,7 +589,7 @@ xfs_dir2_block_log_tail(
mp = tp->t_mountp; mp = tp->t_mountp;
block = bp->data; block = bp->data;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)block), xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)block),
(uint)((char *)(btp + 1) - (char *)block - 1)); (uint)((char *)(btp + 1) - (char *)block - 1));
} }
...@@ -623,13 +623,13 @@ xfs_dir2_block_lookup( ...@@ -623,13 +623,13 @@ xfs_dir2_block_lookup(
mp = dp->i_mount; mp = dp->i_mount;
block = bp->data; block = bp->data;
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Get the offset from the leaf entry, to point to the data. * Get the offset from the leaf entry, to point to the data.
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); ((char *)block + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address)));
/* /*
* Fill in inode number, release the block. * Fill in inode number, release the block.
*/ */
...@@ -675,8 +675,8 @@ xfs_dir2_block_lookup_int( ...@@ -675,8 +675,8 @@ xfs_dir2_block_lookup_int(
ASSERT(bp != NULL); ASSERT(bp != NULL);
block = bp->data; block = bp->data;
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Loop doing a binary search for our hash value. * Loop doing a binary search for our hash value.
* Find our entry, ENOENT if it's not there. * Find our entry, ENOENT if it's not there.
...@@ -713,7 +713,7 @@ xfs_dir2_block_lookup_int( ...@@ -713,7 +713,7 @@ xfs_dir2_block_lookup_int(
* Get pointer to the entry from the leaf. * Get pointer to the entry from the leaf.
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, addr)); ((char *)block + xfs_dir2_dataptr_to_off(mp, addr));
/* /*
* Compare, if it's right give back buffer & entry number. * Compare, if it's right give back buffer & entry number.
*/ */
...@@ -768,20 +768,20 @@ xfs_dir2_block_removename( ...@@ -768,20 +768,20 @@ xfs_dir2_block_removename(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
block = bp->data; block = bp->data;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Point to the data entry using the leaf entry. * Point to the data entry using the leaf entry.
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); ((char *)block + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address)));
/* /*
* Mark the data entry's space free. * Mark the data entry's space free.
*/ */
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, bp, xfs_dir2_data_make_free(tp, bp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)block), (xfs_dir2_data_aoff_t)((char *)dep - (char *)block),
XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
/* /*
* Fix up the block tail. * Fix up the block tail.
*/ */
...@@ -843,13 +843,13 @@ xfs_dir2_block_replace( ...@@ -843,13 +843,13 @@ xfs_dir2_block_replace(
dp = args->dp; dp = args->dp;
mp = dp->i_mount; mp = dp->i_mount;
block = bp->data; block = bp->data;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Point to the data entry we need to change. * Point to the data entry we need to change.
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); ((char *)block + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address)));
ASSERT(be64_to_cpu(dep->inumber) != args->inumber); ASSERT(be64_to_cpu(dep->inumber) != args->inumber);
/* /*
* Change the inode number to the new value. * Change the inode number to the new value.
...@@ -912,7 +912,7 @@ xfs_dir2_leaf_to_block( ...@@ -912,7 +912,7 @@ xfs_dir2_leaf_to_block(
mp = dp->i_mount; mp = dp->i_mount;
leaf = lbp->data; leaf = lbp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
/* /*
* If there are data blocks other than the first one, take this * If there are data blocks other than the first one, take this
* opportunity to remove trailing empty data blocks that may have * opportunity to remove trailing empty data blocks that may have
...@@ -920,7 +920,7 @@ xfs_dir2_leaf_to_block( ...@@ -920,7 +920,7 @@ xfs_dir2_leaf_to_block(
* These will show up in the leaf bests table. * These will show up in the leaf bests table.
*/ */
while (dp->i_d.di_size > mp->m_dirblksize) { while (dp->i_d.di_size > mp->m_dirblksize) {
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
mp->m_dirblksize - (uint)sizeof(block->hdr)) { mp->m_dirblksize - (uint)sizeof(block->hdr)) {
if ((error = if ((error =
...@@ -974,14 +974,14 @@ xfs_dir2_leaf_to_block( ...@@ -974,14 +974,14 @@ xfs_dir2_leaf_to_block(
/* /*
* Initialize the block tail. * Initialize the block tail.
*/ */
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
btp->stale = 0; btp->stale = 0;
xfs_dir2_block_log_tail(tp, dbp); xfs_dir2_block_log_tail(tp, dbp);
/* /*
* Initialize the block leaf area. We compact out stale entries. * Initialize the block leaf area. We compact out stale entries.
*/ */
lep = XFS_DIR2_BLOCK_LEAF_P(btp); lep = xfs_dir2_block_leaf_p(btp);
for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR)
continue; continue;
...@@ -1067,7 +1067,7 @@ xfs_dir2_sf_to_block( ...@@ -1067,7 +1067,7 @@ xfs_dir2_sf_to_block(
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
/* /*
* Copy the directory into the stack buffer. * Copy the directory into the stack buffer.
* Then pitch the incore inode data so we can make extents. * Then pitch the incore inode data so we can make extents.
...@@ -1119,10 +1119,10 @@ xfs_dir2_sf_to_block( ...@@ -1119,10 +1119,10 @@ xfs_dir2_sf_to_block(
/* /*
* Fill in the tail. * Fill in the tail.
*/ */
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
btp->count = cpu_to_be32(sfp->hdr.count + 2); /* ., .. */ btp->count = cpu_to_be32(sfp->hdr.count + 2); /* ., .. */
btp->stale = 0; btp->stale = 0;
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
endoffset = (uint)((char *)blp - (char *)block); endoffset = (uint)((char *)blp - (char *)block);
/* /*
* Remove the freespace, we'll manage it. * Remove the freespace, we'll manage it.
...@@ -1138,25 +1138,25 @@ xfs_dir2_sf_to_block( ...@@ -1138,25 +1138,25 @@ xfs_dir2_sf_to_block(
dep->inumber = cpu_to_be64(dp->i_ino); dep->inumber = cpu_to_be64(dp->i_ino);
dep->namelen = 1; dep->namelen = 1;
dep->name[0] = '.'; dep->name[0] = '.';
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)block); *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep); xfs_dir2_data_log_entry(tp, bp, dep);
blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot);
blp[0].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, blp[0].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
(char *)dep - (char *)block)); (char *)dep - (char *)block));
/* /*
* Create entry for .. * Create entry for ..
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET); ((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET);
dep->inumber = cpu_to_be64(XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent)); dep->inumber = cpu_to_be64(xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent));
dep->namelen = 2; dep->namelen = 2;
dep->name[0] = dep->name[1] = '.'; dep->name[0] = dep->name[1] = '.';
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)block); *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep); xfs_dir2_data_log_entry(tp, bp, dep);
blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot);
blp[1].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, blp[1].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
(char *)dep - (char *)block)); (char *)dep - (char *)block));
offset = XFS_DIR2_DATA_FIRST_OFFSET; offset = XFS_DIR2_DATA_FIRST_OFFSET;
/* /*
...@@ -1165,7 +1165,7 @@ xfs_dir2_sf_to_block( ...@@ -1165,7 +1165,7 @@ xfs_dir2_sf_to_block(
if ((i = 0) == sfp->hdr.count) if ((i = 0) == sfp->hdr.count)
sfep = NULL; sfep = NULL;
else else
sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); sfep = xfs_dir2_sf_firstentry(sfp);
/* /*
* Need to preserve the existing offset values in the sf directory. * Need to preserve the existing offset values in the sf directory.
* Insert holes (unused entries) where necessary. * Insert holes (unused entries) where necessary.
...@@ -1177,7 +1177,7 @@ xfs_dir2_sf_to_block( ...@@ -1177,7 +1177,7 @@ xfs_dir2_sf_to_block(
if (sfep == NULL) if (sfep == NULL)
newoffset = endoffset; newoffset = endoffset;
else else
newoffset = XFS_DIR2_SF_GET_OFFSET(sfep); newoffset = xfs_dir2_sf_get_offset(sfep);
/* /*
* There should be a hole here, make one. * There should be a hole here, make one.
*/ */
...@@ -1186,7 +1186,7 @@ xfs_dir2_sf_to_block( ...@@ -1186,7 +1186,7 @@ xfs_dir2_sf_to_block(
((char *)block + offset); ((char *)block + offset);
dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
dup->length = cpu_to_be16(newoffset - offset); dup->length = cpu_to_be16(newoffset - offset);
*XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16( *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16(
((char *)dup - (char *)block)); ((char *)dup - (char *)block));
xfs_dir2_data_log_unused(tp, bp, dup); xfs_dir2_data_log_unused(tp, bp, dup);
(void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block,
...@@ -1198,22 +1198,22 @@ xfs_dir2_sf_to_block( ...@@ -1198,22 +1198,22 @@ xfs_dir2_sf_to_block(
* Copy a real entry. * Copy a real entry.
*/ */
dep = (xfs_dir2_data_entry_t *)((char *)block + newoffset); dep = (xfs_dir2_data_entry_t *)((char *)block + newoffset);
dep->inumber = cpu_to_be64(XFS_DIR2_SF_GET_INUMBER(sfp, dep->inumber = cpu_to_be64(xfs_dir2_sf_get_inumber(sfp,
XFS_DIR2_SF_INUMBERP(sfep))); xfs_dir2_sf_inumberp(sfep)));
dep->namelen = sfep->namelen; dep->namelen = sfep->namelen;
memcpy(dep->name, sfep->name, dep->namelen); memcpy(dep->name, sfep->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)block); *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep); xfs_dir2_data_log_entry(tp, bp, dep);
blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname( blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname(
(char *)sfep->name, sfep->namelen)); (char *)sfep->name, sfep->namelen));
blp[2 + i].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
(char *)dep - (char *)block)); (char *)dep - (char *)block));
offset = (int)((char *)(tagp + 1) - (char *)block); offset = (int)((char *)(tagp + 1) - (char *)block);
if (++i == sfp->hdr.count) if (++i == sfp->hdr.count)
sfep = NULL; sfep = NULL;
else else
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); sfep = xfs_dir2_sf_nextentry(sfp, sfep);
} }
/* Done with the temporary buffer */ /* Done with the temporary buffer */
kmem_free(buf, buf_len); kmem_free(buf, buf_len);
......
...@@ -60,7 +60,6 @@ typedef struct xfs_dir2_block { ...@@ -60,7 +60,6 @@ typedef struct xfs_dir2_block {
/* /*
* Pointer to the leaf header embedded in a data block (1-block format) * Pointer to the leaf header embedded in a data block (1-block format)
*/ */
#define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block)
static inline xfs_dir2_block_tail_t * static inline xfs_dir2_block_tail_t *
xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
{ {
...@@ -71,7 +70,6 @@ xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) ...@@ -71,7 +70,6 @@ xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
/* /*
* Pointer to the leaf entries embedded in a data block (1-block format) * Pointer to the leaf entries embedded in a data block (1-block format)
*/ */
#define XFS_DIR2_BLOCK_LEAF_P(btp) xfs_dir2_block_leaf_p(btp)
static inline struct xfs_dir2_leaf_entry * static inline struct xfs_dir2_leaf_entry *
xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
{ {
......
...@@ -72,8 +72,8 @@ xfs_dir2_data_check( ...@@ -72,8 +72,8 @@ xfs_dir2_data_check(
bf = d->hdr.bestfree; bf = d->hdr.bestfree;
p = (char *)d->u; p = (char *)d->u;
if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
lep = XFS_DIR2_BLOCK_LEAF_P(btp); lep = xfs_dir2_block_leaf_p(btp);
endp = (char *)lep; endp = (char *)lep;
} else } else
endp = (char *)d + mp->m_dirblksize; endp = (char *)d + mp->m_dirblksize;
...@@ -107,7 +107,7 @@ xfs_dir2_data_check( ...@@ -107,7 +107,7 @@ xfs_dir2_data_check(
*/ */
if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT(lastfree == 0); ASSERT(lastfree == 0);
ASSERT(be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup)) == ASSERT(be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) ==
(char *)dup - (char *)d); (char *)dup - (char *)d);
dfp = xfs_dir2_data_freefind(d, dup); dfp = xfs_dir2_data_freefind(d, dup);
if (dfp) { if (dfp) {
...@@ -131,12 +131,12 @@ xfs_dir2_data_check( ...@@ -131,12 +131,12 @@ xfs_dir2_data_check(
dep = (xfs_dir2_data_entry_t *)p; dep = (xfs_dir2_data_entry_t *)p;
ASSERT(dep->namelen != 0); ASSERT(dep->namelen != 0);
ASSERT(xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)) == 0); ASSERT(xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)) == 0);
ASSERT(be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep)) == ASSERT(be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)) ==
(char *)dep - (char *)d); (char *)dep - (char *)d);
count++; count++;
lastfree = 0; lastfree = 0;
if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
(xfs_dir2_data_aoff_t) (xfs_dir2_data_aoff_t)
((char *)dep - (char *)d)); ((char *)dep - (char *)d));
hash = xfs_da_hashname((char *)dep->name, dep->namelen); hash = xfs_da_hashname((char *)dep->name, dep->namelen);
...@@ -147,7 +147,7 @@ xfs_dir2_data_check( ...@@ -147,7 +147,7 @@ xfs_dir2_data_check(
} }
ASSERT(i < be32_to_cpu(btp->count)); ASSERT(i < be32_to_cpu(btp->count));
} }
p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); p += xfs_dir2_data_entsize(dep->namelen);
} }
/* /*
* Need to have seen all the entries and all the bestfree slots. * Need to have seen all the entries and all the bestfree slots.
...@@ -346,8 +346,8 @@ xfs_dir2_data_freescan( ...@@ -346,8 +346,8 @@ xfs_dir2_data_freescan(
*/ */
p = (char *)d->u; p = (char *)d->u;
if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); endp = (char *)xfs_dir2_block_leaf_p(btp);
} else } else
endp = (char *)d + mp->m_dirblksize; endp = (char *)d + mp->m_dirblksize;
/* /*
...@@ -360,7 +360,7 @@ xfs_dir2_data_freescan( ...@@ -360,7 +360,7 @@ xfs_dir2_data_freescan(
*/ */
if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT((char *)dup - (char *)d == ASSERT((char *)dup - (char *)d ==
be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup))); be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)));
xfs_dir2_data_freeinsert(d, dup, loghead); xfs_dir2_data_freeinsert(d, dup, loghead);
p += be16_to_cpu(dup->length); p += be16_to_cpu(dup->length);
} }
...@@ -370,8 +370,8 @@ xfs_dir2_data_freescan( ...@@ -370,8 +370,8 @@ xfs_dir2_data_freescan(
else { else {
dep = (xfs_dir2_data_entry_t *)p; dep = (xfs_dir2_data_entry_t *)p;
ASSERT((char *)dep - (char *)d == ASSERT((char *)dep - (char *)d ==
be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep))); be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)));
p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); p += xfs_dir2_data_entsize(dep->namelen);
} }
} }
} }
...@@ -402,7 +402,7 @@ xfs_dir2_data_init( ...@@ -402,7 +402,7 @@ xfs_dir2_data_init(
/* /*
* Get the buffer set up for the block. * Get the buffer set up for the block.
*/ */
error = xfs_da_get_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, blkno), -1, &bp, error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp,
XFS_DATA_FORK); XFS_DATA_FORK);
if (error) { if (error) {
return error; return error;
...@@ -427,7 +427,7 @@ xfs_dir2_data_init( ...@@ -427,7 +427,7 @@ xfs_dir2_data_init(
t=mp->m_dirblksize - (uint)sizeof(d->hdr); t=mp->m_dirblksize - (uint)sizeof(d->hdr);
d->hdr.bestfree[0].length = cpu_to_be16(t); d->hdr.bestfree[0].length = cpu_to_be16(t);
dup->length = cpu_to_be16(t); dup->length = cpu_to_be16(t);
*XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16((char *)dup - (char *)d); *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)d);
/* /*
* Log it and return it. * Log it and return it.
*/ */
...@@ -452,7 +452,7 @@ xfs_dir2_data_log_entry( ...@@ -452,7 +452,7 @@ xfs_dir2_data_log_entry(
ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d),
(uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) - (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) -
(char *)d - 1)); (char *)d - 1));
} }
...@@ -497,8 +497,8 @@ xfs_dir2_data_log_unused( ...@@ -497,8 +497,8 @@ xfs_dir2_data_log_unused(
* Log the end (tag) of the unused entry. * Log the end (tag) of the unused entry.
*/ */
xfs_da_log_buf(tp, bp, xfs_da_log_buf(tp, bp,
(uint)((char *)XFS_DIR2_DATA_UNUSED_TAG_P(dup) - (char *)d), (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d),
(uint)((char *)XFS_DIR2_DATA_UNUSED_TAG_P(dup) - (char *)d + (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d +
sizeof(xfs_dir2_data_off_t) - 1)); sizeof(xfs_dir2_data_off_t) - 1));
} }
...@@ -535,8 +535,8 @@ xfs_dir2_data_make_free( ...@@ -535,8 +535,8 @@ xfs_dir2_data_make_free(
xfs_dir2_block_tail_t *btp; /* block tail */ xfs_dir2_block_tail_t *btp; /* block tail */
ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d);
endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
} }
/* /*
* If this isn't the start of the block, then back up to * If this isn't the start of the block, then back up to
...@@ -587,7 +587,7 @@ xfs_dir2_data_make_free( ...@@ -587,7 +587,7 @@ xfs_dir2_data_make_free(
* Fix up the new big freespace. * Fix up the new big freespace.
*/ */
be16_add(&prevdup->length, len + be16_to_cpu(postdup->length)); be16_add(&prevdup->length, len + be16_to_cpu(postdup->length));
*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) = *xfs_dir2_data_unused_tag_p(prevdup) =
cpu_to_be16((char *)prevdup - (char *)d); cpu_to_be16((char *)prevdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, prevdup); xfs_dir2_data_log_unused(tp, bp, prevdup);
if (!needscan) { if (!needscan) {
...@@ -621,7 +621,7 @@ xfs_dir2_data_make_free( ...@@ -621,7 +621,7 @@ xfs_dir2_data_make_free(
else if (prevdup) { else if (prevdup) {
dfp = xfs_dir2_data_freefind(d, prevdup); dfp = xfs_dir2_data_freefind(d, prevdup);
be16_add(&prevdup->length, len); be16_add(&prevdup->length, len);
*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) = *xfs_dir2_data_unused_tag_p(prevdup) =
cpu_to_be16((char *)prevdup - (char *)d); cpu_to_be16((char *)prevdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, prevdup); xfs_dir2_data_log_unused(tp, bp, prevdup);
/* /*
...@@ -649,7 +649,7 @@ xfs_dir2_data_make_free( ...@@ -649,7 +649,7 @@ xfs_dir2_data_make_free(
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = *xfs_dir2_data_unused_tag_p(newdup) =
cpu_to_be16((char *)newdup - (char *)d); cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup); xfs_dir2_data_log_unused(tp, bp, newdup);
/* /*
...@@ -676,7 +676,7 @@ xfs_dir2_data_make_free( ...@@ -676,7 +676,7 @@ xfs_dir2_data_make_free(
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
newdup->length = cpu_to_be16(len); newdup->length = cpu_to_be16(len);
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = *xfs_dir2_data_unused_tag_p(newdup) =
cpu_to_be16((char *)newdup - (char *)d); cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup); xfs_dir2_data_log_unused(tp, bp, newdup);
(void)xfs_dir2_data_freeinsert(d, newdup, needlogp); (void)xfs_dir2_data_freeinsert(d, newdup, needlogp);
...@@ -712,7 +712,7 @@ xfs_dir2_data_use_free( ...@@ -712,7 +712,7 @@ xfs_dir2_data_use_free(
ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
ASSERT(offset >= (char *)dup - (char *)d); ASSERT(offset >= (char *)dup - (char *)d);
ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d); ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d);
ASSERT((char *)dup - (char *)d == be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup))); ASSERT((char *)dup - (char *)d == be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)));
/* /*
* Look up the entry in the bestfree table. * Look up the entry in the bestfree table.
*/ */
...@@ -745,7 +745,7 @@ xfs_dir2_data_use_free( ...@@ -745,7 +745,7 @@ xfs_dir2_data_use_free(
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
newdup->length = cpu_to_be16(oldlen - len); newdup->length = cpu_to_be16(oldlen - len);
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = *xfs_dir2_data_unused_tag_p(newdup) =
cpu_to_be16((char *)newdup - (char *)d); cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup); xfs_dir2_data_log_unused(tp, bp, newdup);
/* /*
...@@ -772,7 +772,7 @@ xfs_dir2_data_use_free( ...@@ -772,7 +772,7 @@ xfs_dir2_data_use_free(
else if (matchback) { else if (matchback) {
newdup = dup; newdup = dup;
newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = *xfs_dir2_data_unused_tag_p(newdup) =
cpu_to_be16((char *)newdup - (char *)d); cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup); xfs_dir2_data_log_unused(tp, bp, newdup);
/* /*
...@@ -799,13 +799,13 @@ xfs_dir2_data_use_free( ...@@ -799,13 +799,13 @@ xfs_dir2_data_use_free(
else { else {
newdup = dup; newdup = dup;
newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup) = *xfs_dir2_data_unused_tag_p(newdup) =
cpu_to_be16((char *)newdup - (char *)d); cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup); xfs_dir2_data_log_unused(tp, bp, newdup);
newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2) = *xfs_dir2_data_unused_tag_p(newdup2) =
cpu_to_be16((char *)newdup2 - (char *)d); cpu_to_be16((char *)newdup2 - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup2); xfs_dir2_data_log_unused(tp, bp, newdup2);
/* /*
......
...@@ -44,7 +44,7 @@ struct xfs_trans; ...@@ -44,7 +44,7 @@ struct xfs_trans;
#define XFS_DIR2_DATA_SPACE 0 #define XFS_DIR2_DATA_SPACE 0
#define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE) #define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
#define XFS_DIR2_DATA_FIRSTDB(mp) \ #define XFS_DIR2_DATA_FIRSTDB(mp) \
XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATA_OFFSET) xfs_dir2_byte_to_db(mp, XFS_DIR2_DATA_OFFSET)
/* /*
* Offsets of . and .. in data space (always block 0) * Offsets of . and .. in data space (always block 0)
...@@ -52,9 +52,9 @@ struct xfs_trans; ...@@ -52,9 +52,9 @@ struct xfs_trans;
#define XFS_DIR2_DATA_DOT_OFFSET \ #define XFS_DIR2_DATA_DOT_OFFSET \
((xfs_dir2_data_aoff_t)sizeof(xfs_dir2_data_hdr_t)) ((xfs_dir2_data_aoff_t)sizeof(xfs_dir2_data_hdr_t))
#define XFS_DIR2_DATA_DOTDOT_OFFSET \ #define XFS_DIR2_DATA_DOTDOT_OFFSET \
(XFS_DIR2_DATA_DOT_OFFSET + XFS_DIR2_DATA_ENTSIZE(1)) (XFS_DIR2_DATA_DOT_OFFSET + xfs_dir2_data_entsize(1))
#define XFS_DIR2_DATA_FIRST_OFFSET \ #define XFS_DIR2_DATA_FIRST_OFFSET \
(XFS_DIR2_DATA_DOTDOT_OFFSET + XFS_DIR2_DATA_ENTSIZE(2)) (XFS_DIR2_DATA_DOTDOT_OFFSET + xfs_dir2_data_entsize(2))
/* /*
* Structures. * Structures.
...@@ -123,7 +123,6 @@ typedef struct xfs_dir2_data { ...@@ -123,7 +123,6 @@ typedef struct xfs_dir2_data {
/* /*
* Size of a data entry. * Size of a data entry.
*/ */
#define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n)
static inline int xfs_dir2_data_entsize(int n) static inline int xfs_dir2_data_entsize(int n)
{ {
return (int)roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \ return (int)roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \
...@@ -133,19 +132,16 @@ static inline int xfs_dir2_data_entsize(int n) ...@@ -133,19 +132,16 @@ static inline int xfs_dir2_data_entsize(int n)
/* /*
* Pointer to an entry's tag word. * Pointer to an entry's tag word.
*/ */
#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep)
static inline __be16 * static inline __be16 *
xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep)
{ {
return (__be16 *)((char *)dep + return (__be16 *)((char *)dep +
XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16)); xfs_dir2_data_entsize(dep->namelen) - sizeof(__be16));
} }
/* /*
* Pointer to a freespace's tag word. * Pointer to a freespace's tag word.
*/ */
#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \
xfs_dir2_data_unused_tag_p(dup)
static inline __be16 * static inline __be16 *
xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup)
{ {
......
...@@ -92,7 +92,7 @@ xfs_dir2_block_to_leaf( ...@@ -92,7 +92,7 @@ xfs_dir2_block_to_leaf(
if ((error = xfs_da_grow_inode(args, &blkno))) { if ((error = xfs_da_grow_inode(args, &blkno))) {
return error; return error;
} }
ldb = XFS_DIR2_DA_TO_DB(mp, blkno); ldb = xfs_dir2_da_to_db(mp, blkno);
ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp)); ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp));
/* /*
* Initialize the leaf block, get a buffer for it. * Initialize the leaf block, get a buffer for it.
...@@ -104,8 +104,8 @@ xfs_dir2_block_to_leaf( ...@@ -104,8 +104,8 @@ xfs_dir2_block_to_leaf(
leaf = lbp->data; leaf = lbp->data;
block = dbp->data; block = dbp->data;
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Set the counts in the leaf header. * Set the counts in the leaf header.
*/ */
...@@ -137,9 +137,9 @@ xfs_dir2_block_to_leaf( ...@@ -137,9 +137,9 @@ xfs_dir2_block_to_leaf(
/* /*
* Set up leaf tail and bests table. * Set up leaf tail and bests table.
*/ */
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
ltp->bestcount = cpu_to_be32(1); ltp->bestcount = cpu_to_be32(1);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
bestsp[0] = block->hdr.bestfree[0].length; bestsp[0] = block->hdr.bestfree[0].length;
/* /*
* Log the data header and leaf bests table. * Log the data header and leaf bests table.
...@@ -209,9 +209,9 @@ xfs_dir2_leaf_addname( ...@@ -209,9 +209,9 @@ xfs_dir2_leaf_addname(
*/ */
index = xfs_dir2_leaf_search_hash(args, lbp); index = xfs_dir2_leaf_search_hash(args, lbp);
leaf = lbp->data; leaf = lbp->data;
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
length = XFS_DIR2_DATA_ENTSIZE(args->namelen); length = xfs_dir2_data_entsize(args->namelen);
/* /*
* See if there are any entries with the same hash value * See if there are any entries with the same hash value
* and space in their block for the new entry. * and space in their block for the new entry.
...@@ -223,7 +223,7 @@ xfs_dir2_leaf_addname( ...@@ -223,7 +223,7 @@ xfs_dir2_leaf_addname(
index++, lep++) { index++, lep++) {
if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue; continue;
i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
ASSERT(i < be32_to_cpu(ltp->bestcount)); ASSERT(i < be32_to_cpu(ltp->bestcount));
ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF);
if (be16_to_cpu(bestsp[i]) >= length) { if (be16_to_cpu(bestsp[i]) >= length) {
...@@ -378,7 +378,7 @@ xfs_dir2_leaf_addname( ...@@ -378,7 +378,7 @@ xfs_dir2_leaf_addname(
*/ */
else { else {
if ((error = if ((error =
xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, use_block), xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block),
-1, &dbp, XFS_DATA_FORK))) { -1, &dbp, XFS_DATA_FORK))) {
xfs_da_brelse(tp, lbp); xfs_da_brelse(tp, lbp);
return error; return error;
...@@ -407,7 +407,7 @@ xfs_dir2_leaf_addname( ...@@ -407,7 +407,7 @@ xfs_dir2_leaf_addname(
dep->inumber = cpu_to_be64(args->inumber); dep->inumber = cpu_to_be64(args->inumber);
dep->namelen = args->namelen; dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen); memcpy(dep->name, args->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)data); *tagp = cpu_to_be16((char *)dep - (char *)data);
/* /*
* Need to scan fix up the bestfree table. * Need to scan fix up the bestfree table.
...@@ -529,7 +529,7 @@ xfs_dir2_leaf_addname( ...@@ -529,7 +529,7 @@ xfs_dir2_leaf_addname(
* Fill in the new leaf entry. * Fill in the new leaf entry.
*/ */
lep->hashval = cpu_to_be32(args->hashval); lep->hashval = cpu_to_be32(args->hashval);
lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block,
be16_to_cpu(*tagp))); be16_to_cpu(*tagp)));
/* /*
* Log the leaf fields and give up the buffers. * Log the leaf fields and give up the buffers.
...@@ -567,13 +567,13 @@ xfs_dir2_leaf_check( ...@@ -567,13 +567,13 @@ xfs_dir2_leaf_check(
* Should factor in the size of the bests table as well. * Should factor in the size of the bests table as well.
* We can deduce a value for that from di_size. * We can deduce a value for that from di_size.
*/ */
ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
/* /*
* Leaves and bests don't overlap. * Leaves and bests don't overlap.
*/ */
ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <= ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
(char *)XFS_DIR2_LEAF_BESTS_P(ltp)); (char *)xfs_dir2_leaf_bests_p(ltp));
/* /*
* Check hash value order, count stale entries. * Check hash value order, count stale entries.
*/ */
...@@ -815,12 +815,12 @@ xfs_dir2_leaf_getdents( ...@@ -815,12 +815,12 @@ xfs_dir2_leaf_getdents(
* Inside the loop we keep the main offset value as a byte offset * Inside the loop we keep the main offset value as a byte offset
* in the directory file. * in the directory file.
*/ */
curoff = XFS_DIR2_DATAPTR_TO_BYTE(mp, uio->uio_offset); curoff = xfs_dir2_dataptr_to_byte(mp, uio->uio_offset);
/* /*
* Force this conversion through db so we truncate the offset * Force this conversion through db so we truncate the offset
* down to get the start of the data block. * down to get the start of the data block.
*/ */
map_off = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, curoff)); map_off = xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, curoff));
/* /*
* Loop over directory entries until we reach the end offset. * Loop over directory entries until we reach the end offset.
* Get more blocks and readahead as necessary. * Get more blocks and readahead as necessary.
...@@ -870,7 +870,7 @@ xfs_dir2_leaf_getdents( ...@@ -870,7 +870,7 @@ xfs_dir2_leaf_getdents(
*/ */
if (1 + ra_want > map_blocks && if (1 + ra_want > map_blocks &&
map_off < map_off <
XFS_DIR2_BYTE_TO_DA(mp, XFS_DIR2_LEAF_OFFSET)) { xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) {
/* /*
* Get more bmaps, fill in after the ones * Get more bmaps, fill in after the ones
* we already have in the table. * we already have in the table.
...@@ -878,7 +878,7 @@ xfs_dir2_leaf_getdents( ...@@ -878,7 +878,7 @@ xfs_dir2_leaf_getdents(
nmap = map_size - map_valid; nmap = map_size - map_valid;
error = xfs_bmapi(tp, dp, error = xfs_bmapi(tp, dp,
map_off, map_off,
XFS_DIR2_BYTE_TO_DA(mp, xfs_dir2_byte_to_da(mp,
XFS_DIR2_LEAF_OFFSET) - map_off, XFS_DIR2_LEAF_OFFSET) - map_off,
XFS_BMAPI_METADATA, NULL, 0, XFS_BMAPI_METADATA, NULL, 0,
&map[map_valid], &nmap, NULL, NULL); &map[map_valid], &nmap, NULL, NULL);
...@@ -903,7 +903,7 @@ xfs_dir2_leaf_getdents( ...@@ -903,7 +903,7 @@ xfs_dir2_leaf_getdents(
map[map_valid + nmap - 1].br_blockcount; map[map_valid + nmap - 1].br_blockcount;
else else
map_off = map_off =
XFS_DIR2_BYTE_TO_DA(mp, xfs_dir2_byte_to_da(mp,
XFS_DIR2_LEAF_OFFSET); XFS_DIR2_LEAF_OFFSET);
/* /*
* Look for holes in the mapping, and * Look for holes in the mapping, and
...@@ -931,14 +931,14 @@ xfs_dir2_leaf_getdents( ...@@ -931,14 +931,14 @@ xfs_dir2_leaf_getdents(
* No valid mappings, so no more data blocks. * No valid mappings, so no more data blocks.
*/ */
if (!map_valid) { if (!map_valid) {
curoff = XFS_DIR2_DA_TO_BYTE(mp, map_off); curoff = xfs_dir2_da_to_byte(mp, map_off);
break; break;
} }
/* /*
* Read the directory block starting at the first * Read the directory block starting at the first
* mapping. * mapping.
*/ */
curdb = XFS_DIR2_DA_TO_DB(mp, map->br_startoff); curdb = xfs_dir2_da_to_db(mp, map->br_startoff);
error = xfs_da_read_buf(tp, dp, map->br_startoff, error = xfs_da_read_buf(tp, dp, map->br_startoff,
map->br_blockcount >= mp->m_dirblkfsbs ? map->br_blockcount >= mp->m_dirblkfsbs ?
XFS_FSB_TO_DADDR(mp, map->br_startblock) : XFS_FSB_TO_DADDR(mp, map->br_startblock) :
...@@ -1014,7 +1014,7 @@ xfs_dir2_leaf_getdents( ...@@ -1014,7 +1014,7 @@ xfs_dir2_leaf_getdents(
/* /*
* Having done a read, we need to set a new offset. * Having done a read, we need to set a new offset.
*/ */
newoff = XFS_DIR2_DB_OFF_TO_BYTE(mp, curdb, 0); newoff = xfs_dir2_db_off_to_byte(mp, curdb, 0);
/* /*
* Start of the current block. * Start of the current block.
*/ */
...@@ -1024,7 +1024,7 @@ xfs_dir2_leaf_getdents( ...@@ -1024,7 +1024,7 @@ xfs_dir2_leaf_getdents(
* Make sure we're in the right block. * Make sure we're in the right block.
*/ */
else if (curoff > newoff) else if (curoff > newoff)
ASSERT(XFS_DIR2_BYTE_TO_DB(mp, curoff) == ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
curdb); curdb);
data = bp->data; data = bp->data;
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
...@@ -1032,7 +1032,7 @@ xfs_dir2_leaf_getdents( ...@@ -1032,7 +1032,7 @@ xfs_dir2_leaf_getdents(
* Find our position in the block. * Find our position in the block.
*/ */
ptr = (char *)&data->u; ptr = (char *)&data->u;
byteoff = XFS_DIR2_BYTE_TO_OFF(mp, curoff); byteoff = xfs_dir2_byte_to_off(mp, curoff);
/* /*
* Skip past the header. * Skip past the header.
*/ */
...@@ -1054,15 +1054,15 @@ xfs_dir2_leaf_getdents( ...@@ -1054,15 +1054,15 @@ xfs_dir2_leaf_getdents(
} }
dep = (xfs_dir2_data_entry_t *)ptr; dep = (xfs_dir2_data_entry_t *)ptr;
length = length =
XFS_DIR2_DATA_ENTSIZE(dep->namelen); xfs_dir2_data_entsize(dep->namelen);
ptr += length; ptr += length;
} }
/* /*
* Now set our real offset. * Now set our real offset.
*/ */
curoff = curoff =
XFS_DIR2_DB_OFF_TO_BYTE(mp, xfs_dir2_db_off_to_byte(mp,
XFS_DIR2_BYTE_TO_DB(mp, curoff), xfs_dir2_byte_to_db(mp, curoff),
(char *)ptr - (char *)data); (char *)ptr - (char *)data);
if (ptr >= (char *)data + mp->m_dirblksize) { if (ptr >= (char *)data + mp->m_dirblksize) {
continue; continue;
...@@ -1091,9 +1091,9 @@ xfs_dir2_leaf_getdents( ...@@ -1091,9 +1091,9 @@ xfs_dir2_leaf_getdents(
p->namelen = dep->namelen; p->namelen = dep->namelen;
length = XFS_DIR2_DATA_ENTSIZE(p->namelen); length = xfs_dir2_data_entsize(p->namelen);
p->cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); p->cook = xfs_dir2_byte_to_dataptr(mp, curoff + length);
p->ino = be64_to_cpu(dep->inumber); p->ino = be64_to_cpu(dep->inumber);
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
...@@ -1121,10 +1121,10 @@ xfs_dir2_leaf_getdents( ...@@ -1121,10 +1121,10 @@ xfs_dir2_leaf_getdents(
* All done. Set output offset value to current offset. * All done. Set output offset value to current offset.
*/ */
*eofp = eof; *eofp = eof;
if (curoff > XFS_DIR2_DATAPTR_TO_BYTE(mp, XFS_DIR2_MAX_DATAPTR)) if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR))
uio->uio_offset = XFS_DIR2_MAX_DATAPTR; uio->uio_offset = XFS_DIR2_MAX_DATAPTR;
else else
uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); uio->uio_offset = xfs_dir2_byte_to_dataptr(mp, curoff);
kmem_free(map, map_size * sizeof(*map)); kmem_free(map, map_size * sizeof(*map));
kmem_free(p, sizeof(*p)); kmem_free(p, sizeof(*p));
if (bp) if (bp)
...@@ -1159,7 +1159,7 @@ xfs_dir2_leaf_init( ...@@ -1159,7 +1159,7 @@ xfs_dir2_leaf_init(
/* /*
* Get the buffer for the block. * Get the buffer for the block.
*/ */
error = xfs_da_get_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, bno), -1, &bp, error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp,
XFS_DATA_FORK); XFS_DATA_FORK);
if (error) { if (error) {
return error; return error;
...@@ -1181,7 +1181,7 @@ xfs_dir2_leaf_init( ...@@ -1181,7 +1181,7 @@ xfs_dir2_leaf_init(
* the block. * the block.
*/ */
if (magic == XFS_DIR2_LEAF1_MAGIC) { if (magic == XFS_DIR2_LEAF1_MAGIC) {
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
ltp->bestcount = 0; ltp->bestcount = 0;
xfs_dir2_leaf_log_tail(tp, bp); xfs_dir2_leaf_log_tail(tp, bp);
} }
...@@ -1206,9 +1206,9 @@ xfs_dir2_leaf_log_bests( ...@@ -1206,9 +1206,9 @@ xfs_dir2_leaf_log_bests(
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; firstb = xfs_dir2_leaf_bests_p(ltp) + first;
lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; lastb = xfs_dir2_leaf_bests_p(ltp) + last;
xfs_da_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), xfs_da_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
(uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1)); (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
} }
...@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_log_tail( ...@@ -1268,7 +1268,7 @@ xfs_dir2_leaf_log_tail(
mp = tp->t_mountp; mp = tp->t_mountp;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
(uint)(mp->m_dirblksize - 1)); (uint)(mp->m_dirblksize - 1));
} }
...@@ -1312,7 +1312,7 @@ xfs_dir2_leaf_lookup( ...@@ -1312,7 +1312,7 @@ xfs_dir2_leaf_lookup(
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data + ((char *)dbp->data +
XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
/* /*
* Return the found inode number. * Return the found inode number.
*/ */
...@@ -1381,7 +1381,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1381,7 +1381,7 @@ xfs_dir2_leaf_lookup_int(
/* /*
* Get the new data block number. * Get the new data block number.
*/ */
newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
/* /*
* If it's not the same as the old data block number, * If it's not the same as the old data block number,
* need to pitch the old one and read the new one. * need to pitch the old one and read the new one.
...@@ -1391,7 +1391,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1391,7 +1391,7 @@ xfs_dir2_leaf_lookup_int(
xfs_da_brelse(tp, dbp); xfs_da_brelse(tp, dbp);
if ((error = if ((error =
xfs_da_read_buf(tp, dp, xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, newdb), -1, &dbp, xfs_dir2_db_to_da(mp, newdb), -1, &dbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
xfs_da_brelse(tp, lbp); xfs_da_brelse(tp, lbp);
return error; return error;
...@@ -1404,7 +1404,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1404,7 +1404,7 @@ xfs_dir2_leaf_lookup_int(
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data + ((char *)dbp->data +
XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
/* /*
* If it matches then return it. * If it matches then return it.
*/ */
...@@ -1469,20 +1469,20 @@ xfs_dir2_leaf_removename( ...@@ -1469,20 +1469,20 @@ xfs_dir2_leaf_removename(
* Point to the leaf entry, use that to point to the data entry. * Point to the leaf entry, use that to point to the data entry.
*/ */
lep = &leaf->ents[index]; lep = &leaf->ents[index];
db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); ((char *)data + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
needscan = needlog = 0; needscan = needlog = 0;
oldbest = be16_to_cpu(data->hdr.bestfree[0].length); oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
ASSERT(be16_to_cpu(bestsp[db]) == oldbest); ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
/* /*
* Mark the former data entry unused. * Mark the former data entry unused.
*/ */
xfs_dir2_data_make_free(tp, dbp, xfs_dir2_data_make_free(tp, dbp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)data), (xfs_dir2_data_aoff_t)((char *)dep - (char *)data),
XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
/* /*
* We just mark the leaf entry stale by putting a null in it. * We just mark the leaf entry stale by putting a null in it.
*/ */
...@@ -1602,7 +1602,7 @@ xfs_dir2_leaf_replace( ...@@ -1602,7 +1602,7 @@ xfs_dir2_leaf_replace(
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data + ((char *)dbp->data +
XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
ASSERT(args->inumber != be64_to_cpu(dep->inumber)); ASSERT(args->inumber != be64_to_cpu(dep->inumber));
/* /*
* Put the new inode number in, log it. * Put the new inode number in, log it.
...@@ -1698,7 +1698,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1698,7 +1698,7 @@ xfs_dir2_leaf_trim_data(
/* /*
* Read the offending data block. We need its buffer. * Read the offending data block. We need its buffer.
*/ */
if ((error = xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, db), -1, &dbp, if ((error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
...@@ -1712,7 +1712,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1712,7 +1712,7 @@ xfs_dir2_leaf_trim_data(
*/ */
leaf = lbp->data; leaf = lbp->data;
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) == ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)); mp->m_dirblksize - (uint)sizeof(data->hdr));
ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
...@@ -1727,7 +1727,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1727,7 +1727,7 @@ xfs_dir2_leaf_trim_data(
/* /*
* Eliminate the last bests entry from the table. * Eliminate the last bests entry from the table.
*/ */
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
be32_add(&ltp->bestcount, -1); be32_add(&ltp->bestcount, -1);
memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp)); memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp));
xfs_dir2_leaf_log_tail(tp, lbp); xfs_dir2_leaf_log_tail(tp, lbp);
...@@ -1838,12 +1838,12 @@ xfs_dir2_node_to_leaf( ...@@ -1838,12 +1838,12 @@ xfs_dir2_node_to_leaf(
/* /*
* Set up the leaf tail from the freespace block. * Set up the leaf tail from the freespace block.
*/ */
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
ltp->bestcount = free->hdr.nvalid; ltp->bestcount = free->hdr.nvalid;
/* /*
* Set up the leaf bests table. * Set up the leaf bests table.
*/ */
memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests, memcpy(xfs_dir2_leaf_bests_p(ltp), free->bests,
be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0])); be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0]));
xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
xfs_dir2_leaf_log_tail(tp, lbp); xfs_dir2_leaf_log_tail(tp, lbp);
......
...@@ -32,7 +32,7 @@ struct xfs_trans; ...@@ -32,7 +32,7 @@ struct xfs_trans;
#define XFS_DIR2_LEAF_SPACE 1 #define XFS_DIR2_LEAF_SPACE 1
#define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE) #define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE)
#define XFS_DIR2_LEAF_FIRSTDB(mp) \ #define XFS_DIR2_LEAF_FIRSTDB(mp) \
XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET) xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)
/* /*
* Offset in data space of a data entry. * Offset in data space of a data entry.
...@@ -82,7 +82,6 @@ typedef struct xfs_dir2_leaf { ...@@ -82,7 +82,6 @@ typedef struct xfs_dir2_leaf {
* DB blocks here are logical directory block numbers, not filesystem blocks. * DB blocks here are logical directory block numbers, not filesystem blocks.
*/ */
#define XFS_DIR2_MAX_LEAF_ENTS(mp) xfs_dir2_max_leaf_ents(mp)
static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp) static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp)
{ {
return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) /
...@@ -92,7 +91,6 @@ static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp) ...@@ -92,7 +91,6 @@ static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp)
/* /*
* Get address of the bestcount field in the single-leaf block. * Get address of the bestcount field in the single-leaf block.
*/ */
#define XFS_DIR2_LEAF_TAIL_P(mp,lp) xfs_dir2_leaf_tail_p(mp, lp)
static inline xfs_dir2_leaf_tail_t * static inline xfs_dir2_leaf_tail_t *
xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp) xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp)
{ {
...@@ -104,7 +102,6 @@ xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp) ...@@ -104,7 +102,6 @@ xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp)
/* /*
* Get address of the bests array in the single-leaf block. * Get address of the bests array in the single-leaf block.
*/ */
#define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp)
static inline __be16 * static inline __be16 *
xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
{ {
...@@ -114,7 +111,6 @@ xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) ...@@ -114,7 +111,6 @@ xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
/* /*
* Convert dataptr to byte in file space * Convert dataptr to byte in file space
*/ */
#define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) xfs_dir2_dataptr_to_byte(mp, dp)
static inline xfs_dir2_off_t static inline xfs_dir2_off_t
xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
{ {
...@@ -124,7 +120,6 @@ xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) ...@@ -124,7 +120,6 @@ xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
/* /*
* Convert byte in file space to dataptr. It had better be aligned. * Convert byte in file space to dataptr. It had better be aligned.
*/ */
#define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) xfs_dir2_byte_to_dataptr(mp,by)
static inline xfs_dir2_dataptr_t static inline xfs_dir2_dataptr_t
xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by) xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by)
{ {
...@@ -134,7 +129,6 @@ xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by) ...@@ -134,7 +129,6 @@ xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by)
/* /*
* Convert byte in space to (DB) block * Convert byte in space to (DB) block
*/ */
#define XFS_DIR2_BYTE_TO_DB(mp,by) xfs_dir2_byte_to_db(mp, by)
static inline xfs_dir2_db_t static inline xfs_dir2_db_t
xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
{ {
...@@ -145,17 +139,15 @@ xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) ...@@ -145,17 +139,15 @@ xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
/* /*
* Convert dataptr to a block number * Convert dataptr to a block number
*/ */
#define XFS_DIR2_DATAPTR_TO_DB(mp,dp) xfs_dir2_dataptr_to_db(mp, dp)
static inline xfs_dir2_db_t static inline xfs_dir2_db_t
xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
{ {
return XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)); return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(mp, dp));
} }
/* /*
* Convert byte in space to offset in a block * Convert byte in space to offset in a block
*/ */
#define XFS_DIR2_BYTE_TO_OFF(mp,by) xfs_dir2_byte_to_off(mp, by)
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
{ {
...@@ -166,18 +158,15 @@ xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) ...@@ -166,18 +158,15 @@ xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
/* /*
* Convert dataptr to a byte offset in a block * Convert dataptr to a byte offset in a block
*/ */
#define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) xfs_dir2_dataptr_to_off(mp, dp)
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
{ {
return XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)); return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(mp, dp));
} }
/* /*
* Convert block and offset to byte in space * Convert block and offset to byte in space
*/ */
#define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \
xfs_dir2_db_off_to_byte(mp, db, o)
static inline xfs_dir2_off_t static inline xfs_dir2_off_t
xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o) xfs_dir2_data_aoff_t o)
...@@ -189,7 +178,6 @@ xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, ...@@ -189,7 +178,6 @@ xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
/* /*
* Convert block (DB) to block (dablk) * Convert block (DB) to block (dablk)
*/ */
#define XFS_DIR2_DB_TO_DA(mp,db) xfs_dir2_db_to_da(mp, db)
static inline xfs_dablk_t static inline xfs_dablk_t
xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
{ {
...@@ -199,29 +187,25 @@ xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) ...@@ -199,29 +187,25 @@ xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
/* /*
* Convert byte in space to (DA) block * Convert byte in space to (DA) block
*/ */
#define XFS_DIR2_BYTE_TO_DA(mp,by) xfs_dir2_byte_to_da(mp, by)
static inline xfs_dablk_t static inline xfs_dablk_t
xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
{ {
return XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by)); return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by));
} }
/* /*
* Convert block and offset to dataptr * Convert block and offset to dataptr
*/ */
#define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \
xfs_dir2_db_off_to_dataptr(mp, db, o)
static inline xfs_dir2_dataptr_t static inline xfs_dir2_dataptr_t
xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
xfs_dir2_data_aoff_t o) xfs_dir2_data_aoff_t o)
{ {
return XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o)); return xfs_dir2_byte_to_dataptr(mp, xfs_dir2_db_off_to_byte(mp, db, o));
} }
/* /*
* Convert block (dablk) to block (DB) * Convert block (dablk) to block (DB)
*/ */
#define XFS_DIR2_DA_TO_DB(mp,da) xfs_dir2_da_to_db(mp, da)
static inline xfs_dir2_db_t static inline xfs_dir2_db_t
xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
{ {
...@@ -231,11 +215,10 @@ xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) ...@@ -231,11 +215,10 @@ xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
/* /*
* Convert block (dablk) to byte offset in space * Convert block (dablk) to byte offset in space
*/ */
#define XFS_DIR2_DA_TO_BYTE(mp,da) xfs_dir2_da_to_byte(mp, da)
static inline xfs_dir2_off_t static inline xfs_dir2_off_t
xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
{ {
return XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0); return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0);
} }
/* /*
......
...@@ -136,14 +136,14 @@ xfs_dir2_leaf_to_node( ...@@ -136,14 +136,14 @@ xfs_dir2_leaf_to_node(
/* /*
* Get the buffer for the new freespace block. * Get the buffer for the new freespace block.
*/ */
if ((error = xfs_da_get_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, fdb), -1, &fbp, if ((error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fdb), -1, &fbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
ASSERT(fbp != NULL); ASSERT(fbp != NULL);
free = fbp->data; free = fbp->data;
leaf = lbp->data; leaf = lbp->data;
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
/* /*
* Initialize the freespace block header. * Initialize the freespace block header.
*/ */
...@@ -155,7 +155,7 @@ xfs_dir2_leaf_to_node( ...@@ -155,7 +155,7 @@ xfs_dir2_leaf_to_node(
* Copy freespace entries from the leaf block to the new block. * Copy freespace entries from the leaf block to the new block.
* Count active entries. * Count active entries.
*/ */
for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests; for (i = n = 0, from = xfs_dir2_leaf_bests_p(ltp), to = free->bests;
i < be32_to_cpu(ltp->bestcount); i++, from++, to++) { i < be32_to_cpu(ltp->bestcount); i++, from++, to++) {
if ((off = be16_to_cpu(*from)) != NULLDATAOFF) if ((off = be16_to_cpu(*from)) != NULLDATAOFF)
n++; n++;
...@@ -215,7 +215,7 @@ xfs_dir2_leafn_add( ...@@ -215,7 +215,7 @@ xfs_dir2_leafn_add(
* a compact. * a compact.
*/ */
if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { if (be16_to_cpu(leaf->hdr.count) == xfs_dir2_max_leaf_ents(mp)) {
if (!leaf->hdr.stale) if (!leaf->hdr.stale)
return XFS_ERROR(ENOSPC); return XFS_ERROR(ENOSPC);
compact = be16_to_cpu(leaf->hdr.stale) > 1; compact = be16_to_cpu(leaf->hdr.stale) > 1;
...@@ -327,7 +327,7 @@ xfs_dir2_leafn_add( ...@@ -327,7 +327,7 @@ xfs_dir2_leafn_add(
* Insert the new entry, log everything. * Insert the new entry, log everything.
*/ */
lep->hashval = cpu_to_be32(args->hashval); lep->hashval = cpu_to_be32(args->hashval);
lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp,
args->blkno, args->index)); args->blkno, args->index));
xfs_dir2_leaf_log_header(tp, bp); xfs_dir2_leaf_log_header(tp, bp);
xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh);
...@@ -352,7 +352,7 @@ xfs_dir2_leafn_check( ...@@ -352,7 +352,7 @@ xfs_dir2_leafn_check(
leaf = bp->data; leaf = bp->data;
mp = dp->i_mount; mp = dp->i_mount;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
if (i + 1 < be16_to_cpu(leaf->hdr.count)) { if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
...@@ -440,7 +440,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -440,7 +440,7 @@ xfs_dir2_leafn_lookup_int(
if (args->addname) { if (args->addname) {
curfdb = curbp ? state->extrablk.blkno : -1; curfdb = curbp ? state->extrablk.blkno : -1;
curdb = -1; curdb = -1;
length = XFS_DIR2_DATA_ENTSIZE(args->namelen); length = xfs_dir2_data_entsize(args->namelen);
if ((free = (curbp ? curbp->data : NULL))) if ((free = (curbp ? curbp->data : NULL)))
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
} }
...@@ -465,7 +465,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -465,7 +465,7 @@ xfs_dir2_leafn_lookup_int(
/* /*
* Pull the data block number from the entry. * Pull the data block number from the entry.
*/ */
newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
/* /*
* For addname, we're looking for a place to put the new entry. * For addname, we're looking for a place to put the new entry.
* We want to use a data block with an entry of equal * We want to use a data block with an entry of equal
...@@ -482,7 +482,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -482,7 +482,7 @@ xfs_dir2_leafn_lookup_int(
* Convert the data block to the free block * Convert the data block to the free block
* holding its freespace information. * holding its freespace information.
*/ */
newfdb = XFS_DIR2_DB_TO_FDB(mp, newdb); newfdb = xfs_dir2_db_to_fdb(mp, newdb);
/* /*
* If it's not the one we have in hand, * If it's not the one we have in hand,
* read it in. * read it in.
...@@ -497,7 +497,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -497,7 +497,7 @@ xfs_dir2_leafn_lookup_int(
* Read the free block. * Read the free block.
*/ */
if ((error = xfs_da_read_buf(tp, dp, if ((error = xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, xfs_dir2_db_to_da(mp,
newfdb), newfdb),
-1, &curbp, -1, &curbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
...@@ -517,7 +517,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -517,7 +517,7 @@ xfs_dir2_leafn_lookup_int(
/* /*
* Get the index for our entry. * Get the index for our entry.
*/ */
fi = XFS_DIR2_DB_TO_FDINDEX(mp, curdb); fi = xfs_dir2_db_to_fdindex(mp, curdb);
/* /*
* If it has room, return it. * If it has room, return it.
*/ */
...@@ -561,7 +561,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -561,7 +561,7 @@ xfs_dir2_leafn_lookup_int(
*/ */
if ((error = if ((error =
xfs_da_read_buf(tp, dp, xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, newdb), -1, xfs_dir2_db_to_da(mp, newdb), -1,
&curbp, XFS_DATA_FORK))) { &curbp, XFS_DATA_FORK))) {
return error; return error;
} }
...@@ -573,7 +573,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -573,7 +573,7 @@ xfs_dir2_leafn_lookup_int(
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)curbp->data + ((char *)curbp->data +
XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
/* /*
* Compare the entry, return it if it matches. * Compare the entry, return it if it matches.
*/ */
...@@ -876,9 +876,9 @@ xfs_dir2_leafn_remove( ...@@ -876,9 +876,9 @@ xfs_dir2_leafn_remove(
/* /*
* Extract the data block and offset from the entry. * Extract the data block and offset from the entry.
*/ */
db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
ASSERT(dblk->blkno == db); ASSERT(dblk->blkno == db);
off = XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)); off = xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address));
ASSERT(dblk->index == off); ASSERT(dblk->index == off);
/* /*
* Kill the leaf entry by marking it stale. * Kill the leaf entry by marking it stale.
...@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove( ...@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove(
longest = be16_to_cpu(data->hdr.bestfree[0].length); longest = be16_to_cpu(data->hdr.bestfree[0].length);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, dbp, off, xfs_dir2_data_make_free(tp, dbp, off,
XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
/* /*
* Rescan the data block freespaces for bestfree. * Rescan the data block freespaces for bestfree.
* Log the data block header if needed. * Log the data block header if needed.
...@@ -924,8 +924,8 @@ xfs_dir2_leafn_remove( ...@@ -924,8 +924,8 @@ xfs_dir2_leafn_remove(
* Convert the data block number to a free block, * Convert the data block number to a free block,
* read in the free block. * read in the free block.
*/ */
fdb = XFS_DIR2_DB_TO_FDB(mp, db); fdb = xfs_dir2_db_to_fdb(mp, db);
if ((error = xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, fdb), if ((error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, fdb),
-1, &fbp, XFS_DATA_FORK))) { -1, &fbp, XFS_DATA_FORK))) {
return error; return error;
} }
...@@ -937,7 +937,7 @@ xfs_dir2_leafn_remove( ...@@ -937,7 +937,7 @@ xfs_dir2_leafn_remove(
/* /*
* Calculate which entry we need to fix. * Calculate which entry we need to fix.
*/ */
findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); findex = xfs_dir2_db_to_fdindex(mp, db);
longest = be16_to_cpu(data->hdr.bestfree[0].length); longest = be16_to_cpu(data->hdr.bestfree[0].length);
/* /*
* If the data block is now empty we can get rid of it * If the data block is now empty we can get rid of it
...@@ -1073,7 +1073,7 @@ xfs_dir2_leafn_split( ...@@ -1073,7 +1073,7 @@ xfs_dir2_leafn_split(
/* /*
* Initialize the new leaf block. * Initialize the new leaf block.
*/ */
error = xfs_dir2_leaf_init(args, XFS_DIR2_DA_TO_DB(mp, blkno), error = xfs_dir2_leaf_init(args, xfs_dir2_da_to_db(mp, blkno),
&newblk->bp, XFS_DIR2_LEAFN_MAGIC); &newblk->bp, XFS_DIR2_LEAFN_MAGIC);
if (error) { if (error) {
return error; return error;
...@@ -1385,7 +1385,7 @@ xfs_dir2_node_addname_int( ...@@ -1385,7 +1385,7 @@ xfs_dir2_node_addname_int(
dp = args->dp; dp = args->dp;
mp = dp->i_mount; mp = dp->i_mount;
tp = args->trans; tp = args->trans;
length = XFS_DIR2_DATA_ENTSIZE(args->namelen); length = xfs_dir2_data_entsize(args->namelen);
/* /*
* If we came in with a freespace block that means that lookup * If we came in with a freespace block that means that lookup
* found an entry with our hash value. This is the freespace * found an entry with our hash value. This is the freespace
...@@ -1438,7 +1438,7 @@ xfs_dir2_node_addname_int( ...@@ -1438,7 +1438,7 @@ xfs_dir2_node_addname_int(
if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK))) if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK)))
return error; return error;
lastfbno = XFS_DIR2_DA_TO_DB(mp, (xfs_dablk_t)fo); lastfbno = xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo);
fbno = ifbno; fbno = ifbno;
} }
/* /*
...@@ -1474,7 +1474,7 @@ xfs_dir2_node_addname_int( ...@@ -1474,7 +1474,7 @@ xfs_dir2_node_addname_int(
* to avoid it. * to avoid it.
*/ */
if ((error = xfs_da_read_buf(tp, dp, if ((error = xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, fbno), -2, &fbp, xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
...@@ -1550,9 +1550,9 @@ xfs_dir2_node_addname_int( ...@@ -1550,9 +1550,9 @@ xfs_dir2_node_addname_int(
* Get the freespace block corresponding to the data block * Get the freespace block corresponding to the data block
* that was just allocated. * that was just allocated.
*/ */
fbno = XFS_DIR2_DB_TO_FDB(mp, dbno); fbno = xfs_dir2_db_to_fdb(mp, dbno);
if (unlikely(error = xfs_da_read_buf(tp, dp, if (unlikely(error = xfs_da_read_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, fbno), -2, &fbp, xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
xfs_da_buf_done(dbp); xfs_da_buf_done(dbp);
return error; return error;
...@@ -1567,14 +1567,14 @@ xfs_dir2_node_addname_int( ...@@ -1567,14 +1567,14 @@ xfs_dir2_node_addname_int(
return error; return error;
} }
if (unlikely(XFS_DIR2_DB_TO_FDB(mp, dbno) != fbno)) { if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) {
cmn_err(CE_ALERT, cmn_err(CE_ALERT,
"xfs_dir2_node_addname_int: dir ino " "xfs_dir2_node_addname_int: dir ino "
"%llu needed freesp block %lld for\n" "%llu needed freesp block %lld for\n"
" data block %lld, got %lld\n" " data block %lld, got %lld\n"
" ifbno %llu lastfbno %d\n", " ifbno %llu lastfbno %d\n",
(unsigned long long)dp->i_ino, (unsigned long long)dp->i_ino,
(long long)XFS_DIR2_DB_TO_FDB(mp, dbno), (long long)xfs_dir2_db_to_fdb(mp, dbno),
(long long)dbno, (long long)fbno, (long long)dbno, (long long)fbno,
(unsigned long long)ifbno, lastfbno); (unsigned long long)ifbno, lastfbno);
if (fblk) { if (fblk) {
...@@ -1598,7 +1598,7 @@ xfs_dir2_node_addname_int( ...@@ -1598,7 +1598,7 @@ xfs_dir2_node_addname_int(
* Get a buffer for the new block. * Get a buffer for the new block.
*/ */
if ((error = xfs_da_get_buf(tp, dp, if ((error = xfs_da_get_buf(tp, dp,
XFS_DIR2_DB_TO_DA(mp, fbno), xfs_dir2_db_to_da(mp, fbno),
-1, &fbp, XFS_DATA_FORK))) { -1, &fbp, XFS_DATA_FORK))) {
return error; return error;
} }
...@@ -1623,7 +1623,7 @@ xfs_dir2_node_addname_int( ...@@ -1623,7 +1623,7 @@ xfs_dir2_node_addname_int(
/* /*
* Set the freespace block index from the data block number. * Set the freespace block index from the data block number.
*/ */
findex = XFS_DIR2_DB_TO_FDINDEX(mp, dbno); findex = xfs_dir2_db_to_fdindex(mp, dbno);
/* /*
* If it's after the end of the current entries in the * If it's after the end of the current entries in the
* freespace block, extend that table. * freespace block, extend that table.
...@@ -1669,7 +1669,7 @@ xfs_dir2_node_addname_int( ...@@ -1669,7 +1669,7 @@ xfs_dir2_node_addname_int(
* Read the data block in. * Read the data block in.
*/ */
if (unlikely( if (unlikely(
error = xfs_da_read_buf(tp, dp, XFS_DIR2_DB_TO_DA(mp, dbno), error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno),
-1, &dbp, XFS_DATA_FORK))) { -1, &dbp, XFS_DATA_FORK))) {
if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL) if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
...@@ -1698,7 +1698,7 @@ xfs_dir2_node_addname_int( ...@@ -1698,7 +1698,7 @@ xfs_dir2_node_addname_int(
dep->inumber = cpu_to_be64(args->inumber); dep->inumber = cpu_to_be64(args->inumber);
dep->namelen = args->namelen; dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen); memcpy(dep->name, args->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)data); *tagp = cpu_to_be16((char *)dep - (char *)data);
xfs_dir2_data_log_entry(tp, dbp, dep); xfs_dir2_data_log_entry(tp, dbp, dep);
/* /*
...@@ -1904,7 +1904,7 @@ xfs_dir2_node_replace( ...@@ -1904,7 +1904,7 @@ xfs_dir2_node_replace(
ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + ((char *)data +
XFS_DIR2_DATAPTR_TO_OFF(state->mp, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address)));
ASSERT(inum != be64_to_cpu(dep->inumber)); ASSERT(inum != be64_to_cpu(dep->inumber));
/* /*
* Fill in the new inode number and log the entry. * Fill in the new inode number and log the entry.
...@@ -1980,7 +1980,7 @@ xfs_dir2_node_trim_free( ...@@ -1980,7 +1980,7 @@ xfs_dir2_node_trim_free(
* Blow the block away. * Blow the block away.
*/ */
if ((error = if ((error =
xfs_dir2_shrink_inode(args, XFS_DIR2_DA_TO_DB(mp, (xfs_dablk_t)fo), xfs_dir2_shrink_inode(args, xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo),
bp))) { bp))) {
/* /*
* Can't fail with ENOSPC since that only happens with no * Can't fail with ENOSPC since that only happens with no
......
...@@ -36,7 +36,7 @@ struct xfs_trans; ...@@ -36,7 +36,7 @@ struct xfs_trans;
#define XFS_DIR2_FREE_SPACE 2 #define XFS_DIR2_FREE_SPACE 2
#define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE) #define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE)
#define XFS_DIR2_FREE_FIRSTDB(mp) \ #define XFS_DIR2_FREE_FIRSTDB(mp) \
XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_FREE_OFFSET) xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)
#define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */
...@@ -60,7 +60,6 @@ typedef struct xfs_dir2_free { ...@@ -60,7 +60,6 @@ typedef struct xfs_dir2_free {
/* /*
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
#define XFS_DIR2_DB_TO_FDB(mp,db) xfs_dir2_db_to_fdb(mp, db)
static inline xfs_dir2_db_t static inline xfs_dir2_db_t
xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
{ {
...@@ -70,7 +69,6 @@ xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) ...@@ -70,7 +69,6 @@ xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
/* /*
* Convert data space db to the corresponding index in a free db. * Convert data space db to the corresponding index in a free db.
*/ */
#define XFS_DIR2_DB_TO_FDINDEX(mp,db) xfs_dir2_db_to_fdindex(mp, db)
static inline int static inline int
xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db) xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
{ {
......
...@@ -89,8 +89,8 @@ xfs_dir2_block_sfsize( ...@@ -89,8 +89,8 @@ xfs_dir2_block_sfsize(
mp = dp->i_mount; mp = dp->i_mount;
count = i8count = namelen = 0; count = i8count = namelen = 0;
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
blp = XFS_DIR2_BLOCK_LEAF_P(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Iterate over the block's data entries by using the leaf pointers. * Iterate over the block's data entries by using the leaf pointers.
...@@ -102,7 +102,7 @@ xfs_dir2_block_sfsize( ...@@ -102,7 +102,7 @@ xfs_dir2_block_sfsize(
* Calculate the pointer to the entry at hand. * Calculate the pointer to the entry at hand.
*/ */
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, addr)); ((char *)block + xfs_dir2_dataptr_to_off(mp, addr));
/* /*
* Detect . and .., so we can special-case them. * Detect . and .., so we can special-case them.
* . is not included in sf directories. * . is not included in sf directories.
...@@ -124,7 +124,7 @@ xfs_dir2_block_sfsize( ...@@ -124,7 +124,7 @@ xfs_dir2_block_sfsize(
/* /*
* Calculate the new size, see if we should give up yet. * Calculate the new size, see if we should give up yet.
*/ */
size = XFS_DIR2_SF_HDR_SIZE(i8count) + /* header */ size = xfs_dir2_sf_hdr_size(i8count) + /* header */
count + /* namelen */ count + /* namelen */
count * (uint)sizeof(xfs_dir2_sf_off_t) + /* offset */ count * (uint)sizeof(xfs_dir2_sf_off_t) + /* offset */
namelen + /* name */ namelen + /* name */
...@@ -139,7 +139,7 @@ xfs_dir2_block_sfsize( ...@@ -139,7 +139,7 @@ xfs_dir2_block_sfsize(
*/ */
sfhp->count = count; sfhp->count = count;
sfhp->i8count = i8count; sfhp->i8count = i8count;
XFS_DIR2_SF_PUT_INUMBER((xfs_dir2_sf_t *)sfhp, &parent, &sfhp->parent); xfs_dir2_sf_put_inumber((xfs_dir2_sf_t *)sfhp, &parent, &sfhp->parent);
return size; return size;
} }
...@@ -199,15 +199,15 @@ xfs_dir2_block_to_sf( ...@@ -199,15 +199,15 @@ xfs_dir2_block_to_sf(
* Copy the header into the newly allocate local space. * Copy the header into the newly allocate local space.
*/ */
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
memcpy(sfp, sfhp, XFS_DIR2_SF_HDR_SIZE(sfhp->i8count)); memcpy(sfp, sfhp, xfs_dir2_sf_hdr_size(sfhp->i8count));
dp->i_d.di_size = size; dp->i_d.di_size = size;
/* /*
* Set up to loop over the block's entries. * Set up to loop over the block's entries.
*/ */
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = xfs_dir2_block_tail_p(mp, block);
ptr = (char *)block->u; ptr = (char *)block->u;
endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); sfep = xfs_dir2_sf_firstentry(sfp);
/* /*
* Loop over the active and unused entries. * Loop over the active and unused entries.
* Stop when we reach the leaf/tail portion of the block. * Stop when we reach the leaf/tail portion of the block.
...@@ -233,22 +233,22 @@ xfs_dir2_block_to_sf( ...@@ -233,22 +233,22 @@ xfs_dir2_block_to_sf(
else if (dep->namelen == 2 && else if (dep->namelen == 2 &&
dep->name[0] == '.' && dep->name[1] == '.') dep->name[0] == '.' && dep->name[1] == '.')
ASSERT(be64_to_cpu(dep->inumber) == ASSERT(be64_to_cpu(dep->inumber) ==
XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent)); xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent));
/* /*
* Normal entry, copy it into shortform. * Normal entry, copy it into shortform.
*/ */
else { else {
sfep->namelen = dep->namelen; sfep->namelen = dep->namelen;
XFS_DIR2_SF_PUT_OFFSET(sfep, xfs_dir2_sf_put_offset(sfep,
(xfs_dir2_data_aoff_t) (xfs_dir2_data_aoff_t)
((char *)dep - (char *)block)); ((char *)dep - (char *)block));
memcpy(sfep->name, dep->name, dep->namelen); memcpy(sfep->name, dep->name, dep->namelen);
temp = be64_to_cpu(dep->inumber); temp = be64_to_cpu(dep->inumber);
XFS_DIR2_SF_PUT_INUMBER(sfp, &temp, xfs_dir2_sf_put_inumber(sfp, &temp,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); sfep = xfs_dir2_sf_nextentry(sfp, sfep);
} }
ptr += XFS_DIR2_DATA_ENTSIZE(dep->namelen); ptr += xfs_dir2_data_entsize(dep->namelen);
} }
ASSERT((char *)sfep - (char *)sfp == size); ASSERT((char *)sfep - (char *)sfp == size);
xfs_dir2_sf_check(args); xfs_dir2_sf_check(args);
...@@ -294,11 +294,11 @@ xfs_dir2_sf_addname( ...@@ -294,11 +294,11 @@ xfs_dir2_sf_addname(
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
/* /*
* Compute entry (and change in) size. * Compute entry (and change in) size.
*/ */
add_entsize = XFS_DIR2_SF_ENTSIZE_BYNAME(sfp, args->namelen); add_entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen);
incr_isize = add_entsize; incr_isize = add_entsize;
objchange = 0; objchange = 0;
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
...@@ -392,7 +392,7 @@ xfs_dir2_sf_addname_easy( ...@@ -392,7 +392,7 @@ xfs_dir2_sf_addname_easy(
/* /*
* Grow the in-inode space. * Grow the in-inode space.
*/ */
xfs_idata_realloc(dp, XFS_DIR2_SF_ENTSIZE_BYNAME(sfp, args->namelen), xfs_idata_realloc(dp, xfs_dir2_sf_entsize_byname(sfp, args->namelen),
XFS_DATA_FORK); XFS_DATA_FORK);
/* /*
* Need to set up again due to realloc of the inode data. * Need to set up again due to realloc of the inode data.
...@@ -403,10 +403,10 @@ xfs_dir2_sf_addname_easy( ...@@ -403,10 +403,10 @@ xfs_dir2_sf_addname_easy(
* Fill in the new entry. * Fill in the new entry.
*/ */
sfep->namelen = args->namelen; sfep->namelen = args->namelen;
XFS_DIR2_SF_PUT_OFFSET(sfep, offset); xfs_dir2_sf_put_offset(sfep, offset);
memcpy(sfep->name, args->name, sfep->namelen); memcpy(sfep->name, args->name, sfep->namelen);
XFS_DIR2_SF_PUT_INUMBER(sfp, &args->inumber, xfs_dir2_sf_put_inumber(sfp, &args->inumber,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
/* /*
* Update the header and inode. * Update the header and inode.
*/ */
...@@ -463,14 +463,14 @@ xfs_dir2_sf_addname_hard( ...@@ -463,14 +463,14 @@ xfs_dir2_sf_addname_hard(
* If it's going to end up at the end then oldsfep will point there. * If it's going to end up at the end then oldsfep will point there.
*/ */
for (offset = XFS_DIR2_DATA_FIRST_OFFSET, for (offset = XFS_DIR2_DATA_FIRST_OFFSET,
oldsfep = XFS_DIR2_SF_FIRSTENTRY(oldsfp), oldsfep = xfs_dir2_sf_firstentry(oldsfp),
add_datasize = XFS_DIR2_DATA_ENTSIZE(args->namelen), add_datasize = xfs_dir2_data_entsize(args->namelen),
eof = (char *)oldsfep == &buf[old_isize]; eof = (char *)oldsfep == &buf[old_isize];
!eof; !eof;
offset = new_offset + XFS_DIR2_DATA_ENTSIZE(oldsfep->namelen), offset = new_offset + xfs_dir2_data_entsize(oldsfep->namelen),
oldsfep = XFS_DIR2_SF_NEXTENTRY(oldsfp, oldsfep), oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep),
eof = (char *)oldsfep == &buf[old_isize]) { eof = (char *)oldsfep == &buf[old_isize]) {
new_offset = XFS_DIR2_SF_GET_OFFSET(oldsfep); new_offset = xfs_dir2_sf_get_offset(oldsfep);
if (offset + add_datasize <= new_offset) if (offset + add_datasize <= new_offset)
break; break;
} }
...@@ -495,10 +495,10 @@ xfs_dir2_sf_addname_hard( ...@@ -495,10 +495,10 @@ xfs_dir2_sf_addname_hard(
* Fill in the new entry, and update the header counts. * Fill in the new entry, and update the header counts.
*/ */
sfep->namelen = args->namelen; sfep->namelen = args->namelen;
XFS_DIR2_SF_PUT_OFFSET(sfep, offset); xfs_dir2_sf_put_offset(sfep, offset);
memcpy(sfep->name, args->name, sfep->namelen); memcpy(sfep->name, args->name, sfep->namelen);
XFS_DIR2_SF_PUT_INUMBER(sfp, &args->inumber, xfs_dir2_sf_put_inumber(sfp, &args->inumber,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
sfp->hdr.count++; sfp->hdr.count++;
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange)
...@@ -508,7 +508,7 @@ xfs_dir2_sf_addname_hard( ...@@ -508,7 +508,7 @@ xfs_dir2_sf_addname_hard(
* If there's more left to copy, do that. * If there's more left to copy, do that.
*/ */
if (!eof) { if (!eof) {
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); sfep = xfs_dir2_sf_nextentry(sfp, sfep);
memcpy(sfep, oldsfep, old_isize - nbytes); memcpy(sfep, oldsfep, old_isize - nbytes);
} }
kmem_free(buf, old_isize); kmem_free(buf, old_isize);
...@@ -544,9 +544,9 @@ xfs_dir2_sf_addname_pick( ...@@ -544,9 +544,9 @@ xfs_dir2_sf_addname_pick(
mp = dp->i_mount; mp = dp->i_mount;
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
size = XFS_DIR2_DATA_ENTSIZE(args->namelen); size = xfs_dir2_data_entsize(args->namelen);
offset = XFS_DIR2_DATA_FIRST_OFFSET; offset = XFS_DIR2_DATA_FIRST_OFFSET;
sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); sfep = xfs_dir2_sf_firstentry(sfp);
holefit = 0; holefit = 0;
/* /*
* Loop over sf entries. * Loop over sf entries.
...@@ -555,10 +555,10 @@ xfs_dir2_sf_addname_pick( ...@@ -555,10 +555,10 @@ xfs_dir2_sf_addname_pick(
*/ */
for (i = 0; i < sfp->hdr.count; i++) { for (i = 0; i < sfp->hdr.count; i++) {
if (!holefit) if (!holefit)
holefit = offset + size <= XFS_DIR2_SF_GET_OFFSET(sfep); holefit = offset + size <= xfs_dir2_sf_get_offset(sfep);
offset = XFS_DIR2_SF_GET_OFFSET(sfep) + offset = xfs_dir2_sf_get_offset(sfep) +
XFS_DIR2_DATA_ENTSIZE(sfep->namelen); xfs_dir2_data_entsize(sfep->namelen);
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); sfep = xfs_dir2_sf_nextentry(sfp, sfep);
} }
/* /*
* Calculate data bytes used excluding the new entry, if this * Calculate data bytes used excluding the new entry, if this
...@@ -617,18 +617,18 @@ xfs_dir2_sf_check( ...@@ -617,18 +617,18 @@ xfs_dir2_sf_check(
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
offset = XFS_DIR2_DATA_FIRST_OFFSET; offset = XFS_DIR2_DATA_FIRST_OFFSET;
ino = XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent); ino = xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent);
i8count = ino > XFS_DIR2_MAX_SHORT_INUM; i8count = ino > XFS_DIR2_MAX_SHORT_INUM;
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep)) { i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
ASSERT(XFS_DIR2_SF_GET_OFFSET(sfep) >= offset); ASSERT(xfs_dir2_sf_get_offset(sfep) >= offset);
ino = XFS_DIR2_SF_GET_INUMBER(sfp, XFS_DIR2_SF_INUMBERP(sfep)); ino = xfs_dir2_sf_get_inumber(sfp, xfs_dir2_sf_inumberp(sfep));
i8count += ino > XFS_DIR2_MAX_SHORT_INUM; i8count += ino > XFS_DIR2_MAX_SHORT_INUM;
offset = offset =
XFS_DIR2_SF_GET_OFFSET(sfep) + xfs_dir2_sf_get_offset(sfep) +
XFS_DIR2_DATA_ENTSIZE(sfep->namelen); xfs_dir2_data_entsize(sfep->namelen);
} }
ASSERT(i8count == sfp->hdr.i8count); ASSERT(i8count == sfp->hdr.i8count);
ASSERT(XFS_BIG_INUMS || i8count == 0); ASSERT(XFS_BIG_INUMS || i8count == 0);
...@@ -671,7 +671,7 @@ xfs_dir2_sf_create( ...@@ -671,7 +671,7 @@ xfs_dir2_sf_create(
ASSERT(dp->i_df.if_flags & XFS_IFINLINE); ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
ASSERT(dp->i_df.if_bytes == 0); ASSERT(dp->i_df.if_bytes == 0);
i8count = pino > XFS_DIR2_MAX_SHORT_INUM; i8count = pino > XFS_DIR2_MAX_SHORT_INUM;
size = XFS_DIR2_SF_HDR_SIZE(i8count); size = xfs_dir2_sf_hdr_size(i8count);
/* /*
* Make a buffer for the data. * Make a buffer for the data.
*/ */
...@@ -684,7 +684,7 @@ xfs_dir2_sf_create( ...@@ -684,7 +684,7 @@ xfs_dir2_sf_create(
/* /*
* Now can put in the inode number, since i8count is set. * Now can put in the inode number, since i8count is set.
*/ */
XFS_DIR2_SF_PUT_INUMBER(sfp, &pino, &sfp->hdr.parent); xfs_dir2_sf_put_inumber(sfp, &pino, &sfp->hdr.parent);
sfp->hdr.count = 0; sfp->hdr.count = 0;
dp->i_d.di_size = size; dp->i_d.di_size = size;
xfs_dir2_sf_check(args); xfs_dir2_sf_check(args);
...@@ -727,12 +727,12 @@ xfs_dir2_sf_getdents( ...@@ -727,12 +727,12 @@ xfs_dir2_sf_getdents(
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
/* /*
* If the block number in the offset is out of range, we're done. * If the block number in the offset is out of range, we're done.
*/ */
if (XFS_DIR2_DATAPTR_TO_DB(mp, dir_offset) > mp->m_dirdatablk) { if (xfs_dir2_dataptr_to_db(mp, dir_offset) > mp->m_dirdatablk) {
*eofp = 1; *eofp = 1;
return 0; return 0;
} }
...@@ -747,9 +747,9 @@ xfs_dir2_sf_getdents( ...@@ -747,9 +747,9 @@ xfs_dir2_sf_getdents(
* Put . entry unless we're starting past it. * Put . entry unless we're starting past it.
*/ */
if (dir_offset <= if (dir_offset <=
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOT_OFFSET)) { XFS_DIR2_DATA_DOT_OFFSET)) {
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, 0, p.cook = xfs_dir2_db_off_to_dataptr(mp, 0,
XFS_DIR2_DATA_DOTDOT_OFFSET); XFS_DIR2_DATA_DOTDOT_OFFSET);
p.ino = dp->i_ino; p.ino = dp->i_ino;
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
...@@ -762,7 +762,7 @@ xfs_dir2_sf_getdents( ...@@ -762,7 +762,7 @@ xfs_dir2_sf_getdents(
if (!p.done) { if (!p.done) {
uio->uio_offset = uio->uio_offset =
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOT_OFFSET); XFS_DIR2_DATA_DOT_OFFSET);
return error; return error;
} }
...@@ -772,11 +772,11 @@ xfs_dir2_sf_getdents( ...@@ -772,11 +772,11 @@ xfs_dir2_sf_getdents(
* Put .. entry unless we're starting past it. * Put .. entry unless we're starting past it.
*/ */
if (dir_offset <= if (dir_offset <=
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOTDOT_OFFSET)) { XFS_DIR2_DATA_DOTDOT_OFFSET)) {
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, p.cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_FIRST_OFFSET); XFS_DIR2_DATA_FIRST_OFFSET);
p.ino = XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent); p.ino = xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent);
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
p.ino += mp->m_inoadd; p.ino += mp->m_inoadd;
#endif #endif
...@@ -787,7 +787,7 @@ xfs_dir2_sf_getdents( ...@@ -787,7 +787,7 @@ xfs_dir2_sf_getdents(
if (!p.done) { if (!p.done) {
uio->uio_offset = uio->uio_offset =
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_DATA_DOTDOT_OFFSET); XFS_DIR2_DATA_DOTDOT_OFFSET);
return error; return error;
} }
...@@ -796,23 +796,23 @@ xfs_dir2_sf_getdents( ...@@ -796,23 +796,23 @@ xfs_dir2_sf_getdents(
/* /*
* Loop while there are more entries and put'ing works. * Loop while there are more entries and put'ing works.
*/ */
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep)) { i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
off = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_SF_GET_OFFSET(sfep)); xfs_dir2_sf_get_offset(sfep));
if (dir_offset > off) if (dir_offset > off)
continue; continue;
p.namelen = sfep->namelen; p.namelen = sfep->namelen;
p.cook = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, p.cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
XFS_DIR2_SF_GET_OFFSET(sfep) + xfs_dir2_sf_get_offset(sfep) +
XFS_DIR2_DATA_ENTSIZE(p.namelen)); xfs_dir2_data_entsize(p.namelen));
p.ino = XFS_DIR2_SF_GET_INUMBER(sfp, XFS_DIR2_SF_INUMBERP(sfep)); p.ino = xfs_dir2_sf_get_inumber(sfp, xfs_dir2_sf_inumberp(sfep));
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
p.ino += mp->m_inoadd; p.ino += mp->m_inoadd;
#endif #endif
...@@ -832,7 +832,7 @@ xfs_dir2_sf_getdents( ...@@ -832,7 +832,7 @@ xfs_dir2_sf_getdents(
*eofp = 1; *eofp = 1;
uio->uio_offset = uio->uio_offset =
XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk + 1, 0); xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0);
return 0; return 0;
} }
...@@ -865,7 +865,7 @@ xfs_dir2_sf_lookup( ...@@ -865,7 +865,7 @@ xfs_dir2_sf_lookup(
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
/* /*
* Special case for . * Special case for .
*/ */
...@@ -878,21 +878,21 @@ xfs_dir2_sf_lookup( ...@@ -878,21 +878,21 @@ xfs_dir2_sf_lookup(
*/ */
if (args->namelen == 2 && if (args->namelen == 2 &&
args->name[0] == '.' && args->name[1] == '.') { args->name[0] == '.' && args->name[1] == '.') {
args->inumber = XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent); args->inumber = xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent);
return XFS_ERROR(EEXIST); return XFS_ERROR(EEXIST);
} }
/* /*
* Loop over all the entries trying to match ours. * Loop over all the entries trying to match ours.
*/ */
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep)) { i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
if (sfep->namelen == args->namelen && if (sfep->namelen == args->namelen &&
sfep->name[0] == args->name[0] && sfep->name[0] == args->name[0] &&
memcmp(args->name, sfep->name, args->namelen) == 0) { memcmp(args->name, sfep->name, args->namelen) == 0) {
args->inumber = args->inumber =
XFS_DIR2_SF_GET_INUMBER(sfp, xfs_dir2_sf_get_inumber(sfp,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
return XFS_ERROR(EEXIST); return XFS_ERROR(EEXIST);
} }
} }
...@@ -934,19 +934,19 @@ xfs_dir2_sf_removename( ...@@ -934,19 +934,19 @@ xfs_dir2_sf_removename(
ASSERT(dp->i_df.if_bytes == oldsize); ASSERT(dp->i_df.if_bytes == oldsize);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(oldsize >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(oldsize >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
/* /*
* Loop over the old directory entries. * Loop over the old directory entries.
* Find the one we're deleting. * Find the one we're deleting.
*/ */
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep)) { i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
if (sfep->namelen == args->namelen && if (sfep->namelen == args->namelen &&
sfep->name[0] == args->name[0] && sfep->name[0] == args->name[0] &&
memcmp(sfep->name, args->name, args->namelen) == 0) { memcmp(sfep->name, args->name, args->namelen) == 0) {
ASSERT(XFS_DIR2_SF_GET_INUMBER(sfp, ASSERT(xfs_dir2_sf_get_inumber(sfp,
XFS_DIR2_SF_INUMBERP(sfep)) == xfs_dir2_sf_inumberp(sfep)) ==
args->inumber); args->inumber);
break; break;
} }
...@@ -961,7 +961,7 @@ xfs_dir2_sf_removename( ...@@ -961,7 +961,7 @@ xfs_dir2_sf_removename(
* Calculate sizes. * Calculate sizes.
*/ */
byteoff = (int)((char *)sfep - (char *)sfp); byteoff = (int)((char *)sfep - (char *)sfp);
entsize = XFS_DIR2_SF_ENTSIZE_BYNAME(sfp, args->namelen); entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen);
newsize = oldsize - entsize; newsize = oldsize - entsize;
/* /*
* Copy the part if any after the removed entry, sliding it down. * Copy the part if any after the removed entry, sliding it down.
...@@ -1027,7 +1027,7 @@ xfs_dir2_sf_replace( ...@@ -1027,7 +1027,7 @@ xfs_dir2_sf_replace(
ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
ASSERT(dp->i_df.if_u1.if_data != NULL); ASSERT(dp->i_df.if_u1.if_data != NULL);
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
ASSERT(dp->i_d.di_size >= XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count)); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count));
#if XFS_BIG_INUMS #if XFS_BIG_INUMS
/* /*
* New inode number is large, and need to convert to 8-byte inodes. * New inode number is large, and need to convert to 8-byte inodes.
...@@ -1067,28 +1067,28 @@ xfs_dir2_sf_replace( ...@@ -1067,28 +1067,28 @@ xfs_dir2_sf_replace(
if (args->namelen == 2 && if (args->namelen == 2 &&
args->name[0] == '.' && args->name[1] == '.') { args->name[0] == '.' && args->name[1] == '.') {
#if XFS_BIG_INUMS || defined(DEBUG) #if XFS_BIG_INUMS || defined(DEBUG)
ino = XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent); ino = xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent);
ASSERT(args->inumber != ino); ASSERT(args->inumber != ino);
#endif #endif
XFS_DIR2_SF_PUT_INUMBER(sfp, &args->inumber, &sfp->hdr.parent); xfs_dir2_sf_put_inumber(sfp, &args->inumber, &sfp->hdr.parent);
} }
/* /*
* Normal entry, look for the name. * Normal entry, look for the name.
*/ */
else { else {
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp); for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep)) { i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
if (sfep->namelen == args->namelen && if (sfep->namelen == args->namelen &&
sfep->name[0] == args->name[0] && sfep->name[0] == args->name[0] &&
memcmp(args->name, sfep->name, args->namelen) == 0) { memcmp(args->name, sfep->name, args->namelen) == 0) {
#if XFS_BIG_INUMS || defined(DEBUG) #if XFS_BIG_INUMS || defined(DEBUG)
ino = XFS_DIR2_SF_GET_INUMBER(sfp, ino = xfs_dir2_sf_get_inumber(sfp,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
ASSERT(args->inumber != ino); ASSERT(args->inumber != ino);
#endif #endif
XFS_DIR2_SF_PUT_INUMBER(sfp, &args->inumber, xfs_dir2_sf_put_inumber(sfp, &args->inumber,
XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_inumberp(sfep));
break; break;
} }
} }
...@@ -1189,22 +1189,22 @@ xfs_dir2_sf_toino4( ...@@ -1189,22 +1189,22 @@ xfs_dir2_sf_toino4(
*/ */
sfp->hdr.count = oldsfp->hdr.count; sfp->hdr.count = oldsfp->hdr.count;
sfp->hdr.i8count = 0; sfp->hdr.i8count = 0;
ino = XFS_DIR2_SF_GET_INUMBER(oldsfp, &oldsfp->hdr.parent); ino = xfs_dir2_sf_get_inumber(oldsfp, &oldsfp->hdr.parent);
XFS_DIR2_SF_PUT_INUMBER(sfp, &ino, &sfp->hdr.parent); xfs_dir2_sf_put_inumber(sfp, &ino, &sfp->hdr.parent);
/* /*
* Copy the entries field by field. * Copy the entries field by field.
*/ */
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp), for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
oldsfep = XFS_DIR2_SF_FIRSTENTRY(oldsfp); oldsfep = xfs_dir2_sf_firstentry(oldsfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep), i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep),
oldsfep = XFS_DIR2_SF_NEXTENTRY(oldsfp, oldsfep)) { oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) {
sfep->namelen = oldsfep->namelen; sfep->namelen = oldsfep->namelen;
sfep->offset = oldsfep->offset; sfep->offset = oldsfep->offset;
memcpy(sfep->name, oldsfep->name, sfep->namelen); memcpy(sfep->name, oldsfep->name, sfep->namelen);
ino = XFS_DIR2_SF_GET_INUMBER(oldsfp, ino = xfs_dir2_sf_get_inumber(oldsfp,
XFS_DIR2_SF_INUMBERP(oldsfep)); xfs_dir2_sf_inumberp(oldsfep));
XFS_DIR2_SF_PUT_INUMBER(sfp, &ino, XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_put_inumber(sfp, &ino, xfs_dir2_sf_inumberp(sfep));
} }
/* /*
* Clean up the inode. * Clean up the inode.
...@@ -1266,22 +1266,22 @@ xfs_dir2_sf_toino8( ...@@ -1266,22 +1266,22 @@ xfs_dir2_sf_toino8(
*/ */
sfp->hdr.count = oldsfp->hdr.count; sfp->hdr.count = oldsfp->hdr.count;
sfp->hdr.i8count = 1; sfp->hdr.i8count = 1;
ino = XFS_DIR2_SF_GET_INUMBER(oldsfp, &oldsfp->hdr.parent); ino = xfs_dir2_sf_get_inumber(oldsfp, &oldsfp->hdr.parent);
XFS_DIR2_SF_PUT_INUMBER(sfp, &ino, &sfp->hdr.parent); xfs_dir2_sf_put_inumber(sfp, &ino, &sfp->hdr.parent);
/* /*
* Copy the entries field by field. * Copy the entries field by field.
*/ */
for (i = 0, sfep = XFS_DIR2_SF_FIRSTENTRY(sfp), for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
oldsfep = XFS_DIR2_SF_FIRSTENTRY(oldsfp); oldsfep = xfs_dir2_sf_firstentry(oldsfp);
i < sfp->hdr.count; i < sfp->hdr.count;
i++, sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep), i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep),
oldsfep = XFS_DIR2_SF_NEXTENTRY(oldsfp, oldsfep)) { oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) {
sfep->namelen = oldsfep->namelen; sfep->namelen = oldsfep->namelen;
sfep->offset = oldsfep->offset; sfep->offset = oldsfep->offset;
memcpy(sfep->name, oldsfep->name, sfep->namelen); memcpy(sfep->name, oldsfep->name, sfep->namelen);
ino = XFS_DIR2_SF_GET_INUMBER(oldsfp, ino = xfs_dir2_sf_get_inumber(oldsfp,
XFS_DIR2_SF_INUMBERP(oldsfep)); xfs_dir2_sf_inumberp(oldsfep));
XFS_DIR2_SF_PUT_INUMBER(sfp, &ino, XFS_DIR2_SF_INUMBERP(sfep)); xfs_dir2_sf_put_inumber(sfp, &ino, xfs_dir2_sf_inumberp(sfep));
} }
/* /*
* Clean up the inode. * Clean up the inode.
......
...@@ -90,7 +90,6 @@ typedef struct xfs_dir2_sf { ...@@ -90,7 +90,6 @@ typedef struct xfs_dir2_sf {
xfs_dir2_sf_entry_t list[1]; /* shortform entries */ xfs_dir2_sf_entry_t list[1]; /* shortform entries */
} xfs_dir2_sf_t; } xfs_dir2_sf_t;
#define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count)
static inline int xfs_dir2_sf_hdr_size(int i8count) static inline int xfs_dir2_sf_hdr_size(int i8count)
{ {
return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \
...@@ -98,14 +97,11 @@ static inline int xfs_dir2_sf_hdr_size(int i8count) ...@@ -98,14 +97,11 @@ static inline int xfs_dir2_sf_hdr_size(int i8count)
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
} }
#define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep)
static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep) static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep)
{ {
return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen]; return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen];
} }
#define XFS_DIR2_SF_GET_INUMBER(sfp, from) \
xfs_dir2_sf_get_inumber(sfp, from)
static inline xfs_intino_t static inline xfs_intino_t
xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from) xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from)
{ {
...@@ -114,8 +110,6 @@ xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from) ...@@ -114,8 +110,6 @@ xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from)
(xfs_intino_t)XFS_GET_DIR_INO8((from)->i8)); (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8));
} }
#define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \
xfs_dir2_sf_put_inumber(sfp,from,to)
static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
xfs_dir2_inou_t *to) xfs_dir2_inou_t *to)
{ {
...@@ -125,24 +119,18 @@ static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, ...@@ -125,24 +119,18 @@ static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from,
XFS_PUT_DIR_INO8(*(from), (to)->i8); XFS_PUT_DIR_INO8(*(from), (to)->i8);
} }
#define XFS_DIR2_SF_GET_OFFSET(sfep) \
xfs_dir2_sf_get_offset(sfep)
static inline xfs_dir2_data_aoff_t static inline xfs_dir2_data_aoff_t
xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep) xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
{ {
return INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i); return INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i);
} }
#define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \
xfs_dir2_sf_put_offset(sfep,off)
static inline void static inline void
xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off) xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
{ {
INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off); INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
} }
#define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \
xfs_dir2_sf_entsize_byname(sfp,len)
static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len) static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len)
{ {
return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
...@@ -150,8 +138,6 @@ static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len) ...@@ -150,8 +138,6 @@ static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len)
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
} }
#define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \
xfs_dir2_sf_entsize_byentry(sfp,sfep)
static inline int static inline int
xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
{ {
...@@ -160,19 +146,17 @@ xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) ...@@ -160,19 +146,17 @@ xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
} }
#define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp)
static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp) static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp)
{ {
return ((xfs_dir2_sf_entry_t *) \ return ((xfs_dir2_sf_entry_t *) \
((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count))); ((char *)(sfp) + xfs_dir2_sf_hdr_size(sfp->hdr.i8count)));
} }
#define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep)
static inline xfs_dir2_sf_entry_t * static inline xfs_dir2_sf_entry_t *
xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep)
{ {
return ((xfs_dir2_sf_entry_t *) \ return ((xfs_dir2_sf_entry_t *) \
((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep))); ((char *)(sfep) + xfs_dir2_sf_entsize_byentry(sfp,sfep)));
} }
/* /*
......
此差异已折叠。
/*
* Copyright (c) 2006-2007 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by 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. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef __XFS_FILESTREAM_H__
#define __XFS_FILESTREAM_H__
#ifdef __KERNEL__
struct xfs_mount;
struct xfs_inode;
struct xfs_perag;
struct xfs_bmalloca;
#ifdef XFS_FILESTREAMS_TRACE
#define XFS_FSTRM_KTRACE_INFO 1
#define XFS_FSTRM_KTRACE_AGSCAN 2
#define XFS_FSTRM_KTRACE_AGPICK1 3
#define XFS_FSTRM_KTRACE_AGPICK2 4
#define XFS_FSTRM_KTRACE_UPDATE 5
#define XFS_FSTRM_KTRACE_FREE 6
#define XFS_FSTRM_KTRACE_ITEM_LOOKUP 7
#define XFS_FSTRM_KTRACE_ASSOCIATE 8
#define XFS_FSTRM_KTRACE_MOVEAG 9
#define XFS_FSTRM_KTRACE_ORPHAN 10
#define XFS_FSTRM_KTRACE_SIZE 16384
extern ktrace_t *xfs_filestreams_trace_buf;
#endif
/*
* Allocation group filestream associations are tracked with per-ag atomic
* counters. These counters allow _xfs_filestream_pick_ag() to tell whether a
* particular AG already has active filestreams associated with it. The mount
* point's m_peraglock is used to protect these counters from per-ag array
* re-allocation during a growfs operation. When xfs_growfs_data_private() is
* about to reallocate the array, it calls xfs_filestream_flush() with the
* m_peraglock held in write mode.
*
* Since xfs_mru_cache_flush() guarantees that all the free functions for all
* the cache elements have finished executing before it returns, it's safe for
* the free functions to use the atomic counters without m_peraglock protection.
* This allows the implementation of xfs_fstrm_free_func() to be agnostic about
* whether it was called with the m_peraglock held in read mode, write mode or
* not held at all. The race condition this addresses is the following:
*
* - The work queue scheduler fires and pulls a filestream directory cache
* element off the LRU end of the cache for deletion, then gets pre-empted.
* - A growfs operation grabs the m_peraglock in write mode, flushes all the
* remaining items from the cache and reallocates the mount point's per-ag
* array, resetting all the counters to zero.
* - The work queue thread resumes and calls the free function for the element
* it started cleaning up earlier. In the process it decrements the
* filestreams counter for an AG that now has no references.
*
* With a shrinkfs feature, the above scenario could panic the system.
*
* All other uses of the following macros should be protected by either the
* m_peraglock held in read mode, or the cache's internal locking exposed by the
* interval between a call to xfs_mru_cache_lookup() and a call to
* xfs_mru_cache_done(). In addition, the m_peraglock must be held in read mode
* when new elements are added to the cache.
*
* Combined, these locking rules ensure that no associations will ever exist in
* the cache that reference per-ag array elements that have since been
* reallocated.
*/
STATIC_INLINE int
xfs_filestream_peek_ag(
xfs_mount_t *mp,
xfs_agnumber_t agno)
{
return atomic_read(&mp->m_perag[agno].pagf_fstrms);
}
STATIC_INLINE int
xfs_filestream_get_ag(
xfs_mount_t *mp,
xfs_agnumber_t agno)
{
return atomic_inc_return(&mp->m_perag[agno].pagf_fstrms);
}
STATIC_INLINE int
xfs_filestream_put_ag(
xfs_mount_t *mp,
xfs_agnumber_t agno)
{
return atomic_dec_return(&mp->m_perag[agno].pagf_fstrms);
}
/* allocation selection flags */
typedef enum xfs_fstrm_alloc {
XFS_PICK_USERDATA = 1,
XFS_PICK_LOWSPACE = 2,
} xfs_fstrm_alloc_t;
/* prototypes for filestream.c */
int xfs_filestream_init(void);
void xfs_filestream_uninit(void);
int xfs_filestream_mount(struct xfs_mount *mp);
void xfs_filestream_unmount(struct xfs_mount *mp);
void xfs_filestream_flush(struct xfs_mount *mp);
xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip);
int xfs_filestream_associate(struct xfs_inode *dip, struct xfs_inode *ip);
void xfs_filestream_deassociate(struct xfs_inode *ip);
int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp);
/* filestreams for the inode? */
STATIC_INLINE int
xfs_inode_is_filestream(
struct xfs_inode *ip)
{
return (ip->i_mount->m_flags & XFS_MOUNT_FILESTREAMS) ||
xfs_iflags_test(ip, XFS_IFILESTREAM) ||
(ip->i_d.di_flags & XFS_DIFLAG_FILESTREAM);
}
#endif /* __KERNEL__ */
#endif /* __XFS_FILESTREAM_H__ */
...@@ -66,6 +66,7 @@ struct fsxattr { ...@@ -66,6 +66,7 @@ struct fsxattr {
#define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */ #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
#define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */ #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
#define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */ #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
#define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
#define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
/* /*
...@@ -238,6 +239,7 @@ typedef struct xfs_fsop_resblks { ...@@ -238,6 +239,7 @@ typedef struct xfs_fsop_resblks {
#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ #define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */
#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ #define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */
#define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */ #define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */
#define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000 /* lazy superblock counters */
/* /*
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "xfs_trans_space.h" #include "xfs_trans_space.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
#include "xfs_rw.h" #include "xfs_rw.h"
#include "xfs_filestream.h"
/* /*
* File system operations * File system operations
...@@ -94,6 +95,8 @@ xfs_fs_geometry( ...@@ -94,6 +95,8 @@ xfs_fs_geometry(
XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) | XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) |
(XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_SECTOR : 0) | XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
(xfs_sb_version_haslazysbcount(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_LAZYSB : 0) |
(XFS_SB_VERSION_HASATTR2(&mp->m_sb) ? (XFS_SB_VERSION_HASATTR2(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_ATTR2 : 0); XFS_FSOP_GEOM_FLAGS_ATTR2 : 0);
geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
...@@ -140,6 +143,8 @@ xfs_growfs_data_private( ...@@ -140,6 +143,8 @@ xfs_growfs_data_private(
pct = in->imaxpct; pct = in->imaxpct;
if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100) if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100)
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
if ((error = xfs_sb_validate_fsb_count(&mp->m_sb, nb)))
return error;
dpct = pct - mp->m_sb.sb_imax_pct; dpct = pct - mp->m_sb.sb_imax_pct;
error = xfs_read_buf(mp, mp->m_ddev_targp, error = xfs_read_buf(mp, mp->m_ddev_targp,
XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1), XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
...@@ -161,6 +166,7 @@ xfs_growfs_data_private( ...@@ -161,6 +166,7 @@ xfs_growfs_data_private(
new = nb - mp->m_sb.sb_dblocks; new = nb - mp->m_sb.sb_dblocks;
oagcount = mp->m_sb.sb_agcount; oagcount = mp->m_sb.sb_agcount;
if (nagcount > oagcount) { if (nagcount > oagcount) {
xfs_filestream_flush(mp);
down_write(&mp->m_peraglock); down_write(&mp->m_peraglock);
mp->m_perag = kmem_realloc(mp->m_perag, mp->m_perag = kmem_realloc(mp->m_perag,
sizeof(xfs_perag_t) * nagcount, sizeof(xfs_perag_t) * nagcount,
...@@ -173,6 +179,7 @@ xfs_growfs_data_private( ...@@ -173,6 +179,7 @@ xfs_growfs_data_private(
up_write(&mp->m_peraglock); up_write(&mp->m_peraglock);
} }
tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
tp->t_flags |= XFS_TRANS_RESERVE;
if ((error = xfs_trans_reserve(tp, XFS_GROWFS_SPACE_RES(mp), if ((error = xfs_trans_reserve(tp, XFS_GROWFS_SPACE_RES(mp),
XFS_GROWDATA_LOG_RES(mp), 0, 0, 0))) { XFS_GROWDATA_LOG_RES(mp), 0, 0, 0))) {
xfs_trans_cancel(tp, 0); xfs_trans_cancel(tp, 0);
...@@ -328,6 +335,7 @@ xfs_growfs_data_private( ...@@ -328,6 +335,7 @@ xfs_growfs_data_private(
be32_add(&agf->agf_length, new); be32_add(&agf->agf_length, new);
ASSERT(be32_to_cpu(agf->agf_length) == ASSERT(be32_to_cpu(agf->agf_length) ==
be32_to_cpu(agi->agi_length)); be32_to_cpu(agi->agi_length));
xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH);
/* /*
* Free the new space. * Free the new space.
*/ */
...@@ -494,8 +502,9 @@ xfs_reserve_blocks( ...@@ -494,8 +502,9 @@ xfs_reserve_blocks(
unsigned long s; unsigned long s;
/* If inval is null, report current values and return */ /* If inval is null, report current values and return */
if (inval == (__uint64_t *)NULL) { if (inval == (__uint64_t *)NULL) {
if (!outval)
return EINVAL;
outval->resblks = mp->m_resblks; outval->resblks = mp->m_resblks;
outval->resblks_avail = mp->m_resblks_avail; outval->resblks_avail = mp->m_resblks_avail;
return 0; return 0;
...@@ -558,8 +567,10 @@ xfs_reserve_blocks( ...@@ -558,8 +567,10 @@ xfs_reserve_blocks(
} }
} }
out: out:
outval->resblks = mp->m_resblks; if (outval) {
outval->resblks_avail = mp->m_resblks_avail; outval->resblks = mp->m_resblks;
outval->resblks_avail = mp->m_resblks_avail;
}
XFS_SB_UNLOCK(mp, s); XFS_SB_UNLOCK(mp, s);
if (fdblks_delta) { if (fdblks_delta) {
......
...@@ -123,6 +123,7 @@ xfs_ialloc_ag_alloc( ...@@ -123,6 +123,7 @@ xfs_ialloc_ag_alloc(
int blks_per_cluster; /* fs blocks per inode cluster */ int blks_per_cluster; /* fs blocks per inode cluster */
xfs_btree_cur_t *cur; /* inode btree cursor */ xfs_btree_cur_t *cur; /* inode btree cursor */
xfs_daddr_t d; /* disk addr of buffer */ xfs_daddr_t d; /* disk addr of buffer */
xfs_agnumber_t agno;
int error; int error;
xfs_buf_t *fbuf; /* new free inodes' buffer */ xfs_buf_t *fbuf; /* new free inodes' buffer */
xfs_dinode_t *free; /* new free inode structure */ xfs_dinode_t *free; /* new free inode structure */
...@@ -302,15 +303,15 @@ xfs_ialloc_ag_alloc( ...@@ -302,15 +303,15 @@ xfs_ialloc_ag_alloc(
} }
be32_add(&agi->agi_count, newlen); be32_add(&agi->agi_count, newlen);
be32_add(&agi->agi_freecount, newlen); be32_add(&agi->agi_freecount, newlen);
agno = be32_to_cpu(agi->agi_seqno);
down_read(&args.mp->m_peraglock); down_read(&args.mp->m_peraglock);
args.mp->m_perag[be32_to_cpu(agi->agi_seqno)].pagi_freecount += newlen; args.mp->m_perag[agno].pagi_freecount += newlen;
up_read(&args.mp->m_peraglock); up_read(&args.mp->m_peraglock);
agi->agi_newino = cpu_to_be32(newino); agi->agi_newino = cpu_to_be32(newino);
/* /*
* Insert records describing the new inode chunk into the btree. * Insert records describing the new inode chunk into the btree.
*/ */
cur = xfs_btree_init_cursor(args.mp, tp, agbp, cur = xfs_btree_init_cursor(args.mp, tp, agbp, agno,
be32_to_cpu(agi->agi_seqno),
XFS_BTNUM_INO, (xfs_inode_t *)0, 0); XFS_BTNUM_INO, (xfs_inode_t *)0, 0);
for (thisino = newino; for (thisino = newino;
thisino < newino + newlen; thisino < newino + newlen;
...@@ -1387,6 +1388,7 @@ xfs_ialloc_read_agi( ...@@ -1387,6 +1388,7 @@ xfs_ialloc_read_agi(
pag = &mp->m_perag[agno]; pag = &mp->m_perag[agno];
if (!pag->pagi_init) { if (!pag->pagi_init) {
pag->pagi_freecount = be32_to_cpu(agi->agi_freecount); pag->pagi_freecount = be32_to_cpu(agi->agi_freecount);
pag->pagi_count = be32_to_cpu(agi->agi_count);
pag->pagi_init = 1; pag->pagi_init = 1;
} else { } else {
/* /*
...@@ -1410,3 +1412,23 @@ xfs_ialloc_read_agi( ...@@ -1410,3 +1412,23 @@ xfs_ialloc_read_agi(
*bpp = bp; *bpp = bp;
return 0; return 0;
} }
/*
* Read in the agi to initialise the per-ag data in the mount structure
*/
int
xfs_ialloc_pagi_init(
xfs_mount_t *mp, /* file system mount structure */
xfs_trans_t *tp, /* transaction pointer */
xfs_agnumber_t agno) /* allocation group number */
{
xfs_buf_t *bp = NULL;
int error;
error = xfs_ialloc_read_agi(mp, tp, agno, &bp);
if (error)
return error;
if (bp)
xfs_trans_brelse(tp, bp);
return 0;
}
...@@ -149,6 +149,16 @@ xfs_ialloc_read_agi( ...@@ -149,6 +149,16 @@ xfs_ialloc_read_agi(
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
struct xfs_buf **bpp); /* allocation group hdr buf */ struct xfs_buf **bpp); /* allocation group hdr buf */
/*
* Read in the allocation group header to initialise the per-ag data
* in the mount structure
*/
int
xfs_ialloc_pagi_init(
struct xfs_mount *mp, /* file system mount structure */
struct xfs_trans *tp, /* transaction pointer */
xfs_agnumber_t agno); /* allocation group number */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* __XFS_IALLOC_H__ */ #endif /* __XFS_IALLOC_H__ */
...@@ -48,7 +48,9 @@ ...@@ -48,7 +48,9 @@
#include "xfs_dir2_trace.h" #include "xfs_dir2_trace.h"
#include "xfs_quota.h" #include "xfs_quota.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_filestream.h"
#include <linux/log2.h>
kmem_zone_t *xfs_ifork_zone; kmem_zone_t *xfs_ifork_zone;
kmem_zone_t *xfs_inode_zone; kmem_zone_t *xfs_inode_zone;
...@@ -643,8 +645,7 @@ xfs_iformat_extents( ...@@ -643,8 +645,7 @@ xfs_iformat_extents(
ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1),
ARCH_CONVERT); ARCH_CONVERT);
} }
xfs_bmap_trace_exlist("xfs_iformat_extents", ip, nex, XFS_BMAP_TRACE_EXLIST(ip, nex, whichfork);
whichfork);
if (whichfork != XFS_DATA_FORK || if (whichfork != XFS_DATA_FORK ||
XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE) XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE)
if (unlikely(xfs_check_nostate_extents( if (unlikely(xfs_check_nostate_extents(
...@@ -817,6 +818,8 @@ _xfs_dic2xflags( ...@@ -817,6 +818,8 @@ _xfs_dic2xflags(
flags |= XFS_XFLAG_EXTSZINHERIT; flags |= XFS_XFLAG_EXTSZINHERIT;
if (di_flags & XFS_DIFLAG_NODEFRAG) if (di_flags & XFS_DIFLAG_NODEFRAG)
flags |= XFS_XFLAG_NODEFRAG; flags |= XFS_XFLAG_NODEFRAG;
if (di_flags & XFS_DIFLAG_FILESTREAM)
flags |= XFS_XFLAG_FILESTREAM;
} }
return flags; return flags;
...@@ -1074,6 +1077,11 @@ xfs_iread_extents( ...@@ -1074,6 +1077,11 @@ xfs_iread_extents(
* also returns the [locked] bp pointing to the head of the freelist * also returns the [locked] bp pointing to the head of the freelist
* as ialloc_context. The caller should hold this buffer across * as ialloc_context. The caller should hold this buffer across
* the commit and pass it back into this routine on the second call. * the commit and pass it back into this routine on the second call.
*
* If we are allocating quota inodes, we do not have a parent inode
* to attach to or associate with (i.e. pip == NULL) because they
* are not linked into the directory structure - they are attached
* directly to the superblock - and so have no parent.
*/ */
int int
xfs_ialloc( xfs_ialloc(
...@@ -1099,7 +1107,7 @@ xfs_ialloc( ...@@ -1099,7 +1107,7 @@ xfs_ialloc(
* Call the space management code to pick * Call the space management code to pick
* the on-disk inode to be allocated. * the on-disk inode to be allocated.
*/ */
error = xfs_dialloc(tp, pip->i_ino, mode, okalloc, error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc,
ialloc_context, call_again, &ino); ialloc_context, call_again, &ino);
if (error != 0) { if (error != 0) {
return error; return error;
...@@ -1150,10 +1158,10 @@ xfs_ialloc( ...@@ -1150,10 +1158,10 @@ xfs_ialloc(
/* /*
* Project ids won't be stored on disk if we are using a version 1 inode. * Project ids won't be stored on disk if we are using a version 1 inode.
*/ */
if ( (prid != 0) && (ip->i_d.di_version == XFS_DINODE_VERSION_1)) if ((prid != 0) && (ip->i_d.di_version == XFS_DINODE_VERSION_1))
xfs_bump_ino_vers2(tp, ip); xfs_bump_ino_vers2(tp, ip);
if (XFS_INHERIT_GID(pip, vp->v_vfsp)) { if (pip && XFS_INHERIT_GID(pip, vp->v_vfsp)) {
ip->i_d.di_gid = pip->i_d.di_gid; ip->i_d.di_gid = pip->i_d.di_gid;
if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) { if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) {
ip->i_d.di_mode |= S_ISGID; ip->i_d.di_mode |= S_ISGID;
...@@ -1195,8 +1203,16 @@ xfs_ialloc( ...@@ -1195,8 +1203,16 @@ xfs_ialloc(
flags |= XFS_ILOG_DEV; flags |= XFS_ILOG_DEV;
break; break;
case S_IFREG: case S_IFREG:
if (pip && xfs_inode_is_filestream(pip)) {
error = xfs_filestream_associate(pip, ip);
if (error < 0)
return -error;
if (!error)
xfs_iflags_set(ip, XFS_IFILESTREAM);
}
/* fall through */
case S_IFDIR: case S_IFDIR:
if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) { if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
uint di_flags = 0; uint di_flags = 0;
if ((mode & S_IFMT) == S_IFDIR) { if ((mode & S_IFMT) == S_IFDIR) {
...@@ -1233,6 +1249,8 @@ xfs_ialloc( ...@@ -1233,6 +1249,8 @@ xfs_ialloc(
if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) && if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) &&
xfs_inherit_nodefrag) xfs_inherit_nodefrag)
di_flags |= XFS_DIFLAG_NODEFRAG; di_flags |= XFS_DIFLAG_NODEFRAG;
if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
di_flags |= XFS_DIFLAG_FILESTREAM;
ip->i_d.di_flags |= di_flags; ip->i_d.di_flags |= di_flags;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
...@@ -2875,9 +2893,6 @@ xfs_iextents_copy( ...@@ -2875,9 +2893,6 @@ xfs_iextents_copy(
int copied; int copied;
xfs_bmbt_rec_t *dest_ep; xfs_bmbt_rec_t *dest_ep;
xfs_bmbt_rec_t *ep; xfs_bmbt_rec_t *ep;
#ifdef XFS_BMAP_TRACE
static char fname[] = "xfs_iextents_copy";
#endif
int i; int i;
xfs_ifork_t *ifp; xfs_ifork_t *ifp;
int nrecs; int nrecs;
...@@ -2888,7 +2903,7 @@ xfs_iextents_copy( ...@@ -2888,7 +2903,7 @@ xfs_iextents_copy(
ASSERT(ifp->if_bytes > 0); ASSERT(ifp->if_bytes > 0);
nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
xfs_bmap_trace_exlist(fname, ip, nrecs, whichfork); XFS_BMAP_TRACE_EXLIST(ip, nrecs, whichfork);
ASSERT(nrecs > 0); ASSERT(nrecs > 0);
/* /*
...@@ -4184,7 +4199,7 @@ xfs_iext_realloc_direct( ...@@ -4184,7 +4199,7 @@ xfs_iext_realloc_direct(
ifp->if_bytes = new_size; ifp->if_bytes = new_size;
return; return;
} }
if ((new_size & (new_size - 1)) != 0) { if (!is_power_of_2(new_size)){
rnew_size = xfs_iroundup(new_size); rnew_size = xfs_iroundup(new_size);
} }
if (rnew_size != ifp->if_real_bytes) { if (rnew_size != ifp->if_real_bytes) {
...@@ -4207,7 +4222,7 @@ xfs_iext_realloc_direct( ...@@ -4207,7 +4222,7 @@ xfs_iext_realloc_direct(
*/ */
else { else {
new_size += ifp->if_bytes; new_size += ifp->if_bytes;
if ((new_size & (new_size - 1)) != 0) { if (!is_power_of_2(new_size)) {
rnew_size = xfs_iroundup(new_size); rnew_size = xfs_iroundup(new_size);
} }
xfs_iext_inline_to_direct(ifp, rnew_size); xfs_iext_inline_to_direct(ifp, rnew_size);
......
...@@ -379,6 +379,7 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) ...@@ -379,6 +379,7 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
#define XFS_ISTALE 0x0010 /* inode has been staled */ #define XFS_ISTALE 0x0010 /* inode has been staled */
#define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */ #define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */
#define XFS_INEW 0x0040 #define XFS_INEW 0x0040
#define XFS_IFILESTREAM 0x0080 /* inode is in a filestream directory */
/* /*
* Flags for inode locking. * Flags for inode locking.
...@@ -414,19 +415,22 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) ...@@ -414,19 +415,22 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
* gets a lockdep subclass of 1 and the second lock will have a lockdep * gets a lockdep subclass of 1 and the second lock will have a lockdep
* subclass of 0. * subclass of 0.
* *
* XFS_I[O]LOCK_INUMORDER - for locking several inodes at the some time * XFS_LOCK_INUMORDER - for locking several inodes at the some time
* with xfs_lock_inodes(). This flag is used as the starting subclass * with xfs_lock_inodes(). This flag is used as the starting subclass
* and each subsequent lock acquired will increment the subclass by one. * and each subsequent lock acquired will increment the subclass by one.
* So the first lock acquired will have a lockdep subclass of 2, the * So the first lock acquired will have a lockdep subclass of 2, the
* second lock will have a lockdep subclass of 3, and so on. * second lock will have a lockdep subclass of 3, and so on. It is
* the responsibility of the class builder to shift this to the correct
* portion of the lock_mode lockdep mask.
*/ */
#define XFS_LOCK_PARENT 1
#define XFS_LOCK_INUMORDER 2
#define XFS_IOLOCK_SHIFT 16 #define XFS_IOLOCK_SHIFT 16
#define XFS_IOLOCK_PARENT (1 << XFS_IOLOCK_SHIFT) #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT)
#define XFS_IOLOCK_INUMORDER (2 << XFS_IOLOCK_SHIFT)
#define XFS_ILOCK_SHIFT 24 #define XFS_ILOCK_SHIFT 24
#define XFS_ILOCK_PARENT (1 << XFS_ILOCK_SHIFT) #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT)
#define XFS_ILOCK_INUMORDER (2 << XFS_ILOCK_SHIFT)
#define XFS_IOLOCK_DEP_MASK 0x00ff0000 #define XFS_IOLOCK_DEP_MASK 0x00ff0000
#define XFS_ILOCK_DEP_MASK 0xff000000 #define XFS_ILOCK_DEP_MASK 0xff000000
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -927,6 +927,14 @@ xlog_find_tail( ...@@ -927,6 +927,14 @@ xlog_find_tail(
ASSIGN_ANY_LSN_HOST(log->l_last_sync_lsn, log->l_curr_cycle, ASSIGN_ANY_LSN_HOST(log->l_last_sync_lsn, log->l_curr_cycle,
after_umount_blk); after_umount_blk);
*tail_blk = after_umount_blk; *tail_blk = after_umount_blk;
/*
* Note that the unmount was clean. If the unmount
* was not clean, we need to know this to rebuild the
* superblock counters from the perag headers if we
* have a filesystem using non-persistent counters.
*/
log->l_mp->m_flags |= XFS_MOUNT_WAS_CLEAN;
} }
} }
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -1882,11 +1882,13 @@ xfs_growfs_rt( ...@@ -1882,11 +1882,13 @@ xfs_growfs_rt(
(nrblocks = in->newblocks) <= sbp->sb_rblocks || (nrblocks = in->newblocks) <= sbp->sb_rblocks ||
(sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize))) (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize)))
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
if ((error = xfs_sb_validate_fsb_count(sbp, nrblocks)))
return error;
/* /*
* Read in the last block of the device, make sure it exists. * Read in the last block of the device, make sure it exists.
*/ */
error = xfs_read_buf(mp, mp->m_rtdev_targp, error = xfs_read_buf(mp, mp->m_rtdev_targp,
XFS_FSB_TO_BB(mp, in->newblocks - 1), XFS_FSB_TO_BB(mp, nrblocks - 1),
XFS_FSB_TO_BB(mp, 1), 0, &bp); XFS_FSB_TO_BB(mp, 1), 0, &bp);
if (error) if (error)
return error; return error;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册