Skip to content

Commit

Permalink
Merge git://oss.sgi.com:8090/xfs/xfs-2.6
Browse files Browse the repository at this point in the history
* git://oss.sgi.com:8090/xfs/xfs-2.6: (49 commits)
  [XFS] Remove v1 dir trace macro - missed in a past commit.
  [XFS] 955947: Infinite loop in xfs_bulkstat() on formatter() error
  [XFS] pv 956241, author: nathans, rv: vapo - make ino validation checks
  [XFS] pv 956240, author: nathans, rv: vapo - Minor fixes in
  [XFS] Really fix use after free in xfs_iunpin.
  [XFS] Collapse sv_init and init_sv into just the one interface.
  [XFS] standardize on one sema init macro
  [XFS] Reduce endian flipping in alloc_btree, same as was done for
  [XFS] Minor cleanup from dio locking fix, remove an extra conditional.
  [XFS] Fix kmem_zalloc_greedy warnings on 64 bit platforms.
  [XFS] pv 955157, rv bnaujok - break the loop on EFAULT formatter() error
  [XFS] pv 955157, rv bnaujok - break the loop on formatter() error
  [XFS] Fixes the leak in reservation space because we weren't ungranting
  [XFS] Add lock annotations to xfs_trans_update_ail and
  [XFS] Fix a porting botch on the realtime subvol growfs code path.
  [XFS] Minor code rearranging and cleanup to prevent some coverity false
  [XFS] Remove a no-longer-correct debug assert from dio completion
  [XFS] Add a greedy allocation interface, allocating within a min/max size
  [XFS] Improve error handling for the zero-fsblock extent detection code.
  [XFS] Be more defensive with page flags (error/private) for metadata
  ...
  • Loading branch information
Linus Torvalds committed Sep 29, 2006
2 parents ae1390d + 1b06e79 commit c0341b0
Show file tree
Hide file tree
Showing 64 changed files with 1,060 additions and 1,037 deletions.
1 change: 0 additions & 1 deletion fs/xfs/Makefile-linux-2.6
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ifeq ($(CONFIG_XFS_TRACE),y)
EXTRA_CFLAGS += -DXFS_BLI_TRACE
EXTRA_CFLAGS += -DXFS_BMAP_TRACE
EXTRA_CFLAGS += -DXFS_BMBT_TRACE
EXTRA_CFLAGS += -DXFS_DIR_TRACE
EXTRA_CFLAGS += -DXFS_DIR2_TRACE
EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
Expand Down
29 changes: 29 additions & 0 deletions fs/xfs/linux-2.6/kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;

#ifdef DEBUG
if (unlikely(!(flags & KM_LARGE) && (size > PAGE_SIZE))) {
printk(KERN_WARNING "Large %s attempt, size=%ld\n",
__FUNCTION__, (long)size);
dump_stack();
}
#endif

do {
if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS)
ptr = kmalloc(size, lflags);
Expand All @@ -60,6 +68,27 @@ kmem_zalloc(size_t size, unsigned int __nocast flags)
return ptr;
}

void *
kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
unsigned int __nocast flags)
{
void *ptr;
size_t kmsize = maxsize;
unsigned int kmflags = (flags & ~KM_SLEEP) | KM_NOSLEEP;

while (!(ptr = kmem_zalloc(kmsize, kmflags))) {
if ((kmsize <= minsize) && (flags & KM_NOSLEEP))
break;
if ((kmsize >>= 1) <= minsize) {
kmsize = minsize;
kmflags = flags;
}
}
if (ptr)
*size = kmsize;
return ptr;
}

void
kmem_free(void *ptr, size_t size)
{
Expand Down
6 changes: 4 additions & 2 deletions fs/xfs/linux-2.6/kmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define KM_NOSLEEP 0x0002u
#define KM_NOFS 0x0004u
#define KM_MAYFAIL 0x0008u
#define KM_LARGE 0x0010u

/*
* We use a special process flag to avoid recursive callbacks into
Expand All @@ -41,7 +42,7 @@ kmem_flags_convert(unsigned int __nocast flags)
{
gfp_t lflags;

BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL));
BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL|KM_LARGE));

if (flags & KM_NOSLEEP) {
lflags = GFP_ATOMIC | __GFP_NOWARN;
Expand All @@ -54,8 +55,9 @@ kmem_flags_convert(unsigned int __nocast flags)
}

extern void *kmem_alloc(size_t, unsigned int __nocast);
extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
extern void *kmem_zalloc(size_t, unsigned int __nocast);
extern void *kmem_zalloc_greedy(size_t *, size_t, size_t, unsigned int __nocast);
extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
extern void kmem_free(void *, size_t);

/*
Expand Down
2 changes: 0 additions & 2 deletions fs/xfs/linux-2.6/sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

typedef struct semaphore sema_t;

#define init_sema(sp, val, c, d) sema_init(sp, val)
#define initsema(sp, val) sema_init(sp, val)
#define initnsema(sp, val, name) sema_init(sp, val)
#define psema(sp, b) down(sp)
#define vsema(sp) up(sp)
Expand Down
2 changes: 0 additions & 2 deletions fs/xfs/linux-2.6/sv.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ static inline void _sv_wait(sv_t *sv, spinlock_t *lock, int state,
remove_wait_queue(&sv->waiters, &wait);
}

#define init_sv(sv,type,name,flag) \
init_waitqueue_head(&(sv)->waiters)
#define sv_init(sv,flag,name) \
init_waitqueue_head(&(sv)->waiters)
#define sv_destroy(sv) \
Expand Down
9 changes: 4 additions & 5 deletions fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ xfs_page_trace(
int tag,
struct inode *inode,
struct page *page,
int mask)
unsigned long pgoff)
{
xfs_inode_t *ip;
bhv_vnode_t *vp = vn_from_inode(inode);
Expand All @@ -91,7 +91,7 @@ xfs_page_trace(
(void *)ip,
(void *)inode,
(void *)page,
(void *)((unsigned long)mask),
(void *)pgoff,
(void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
(void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
(void *)((unsigned long)((isize >> 32) & 0xffffffff)),
Expand All @@ -105,7 +105,7 @@ xfs_page_trace(
(void *)NULL);
}
#else
#define xfs_page_trace(tag, inode, page, mask)
#define xfs_page_trace(tag, inode, page, pgoff)
#endif

/*
Expand Down Expand Up @@ -1197,7 +1197,7 @@ xfs_vm_releasepage(
.nr_to_write = 1,
};

xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, 0);

if (!page_has_buffers(page))
return 0;
Expand Down Expand Up @@ -1356,7 +1356,6 @@ xfs_end_io_direct(
ioend->io_size = size;
xfs_finish_ioend(ioend);
} else {
ASSERT(size >= 0);
xfs_destroy_ioend(ioend);
}

Expand Down
51 changes: 30 additions & 21 deletions fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
* Copyright (c) 2000-2006 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -318,8 +318,12 @@ xfs_buf_free(
if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1))
free_address(bp->b_addr - bp->b_offset);

for (i = 0; i < bp->b_page_count; i++)
page_cache_release(bp->b_pages[i]);
for (i = 0; i < bp->b_page_count; i++) {
struct page *page = bp->b_pages[i];

ASSERT(!PagePrivate(page));
page_cache_release(page);
}
_xfs_buf_free_pages(bp);
} else if (bp->b_flags & _XBF_KMEM_ALLOC) {
/*
Expand Down Expand Up @@ -400,6 +404,7 @@ _xfs_buf_lookup_pages(
nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset);
size -= nbytes;

ASSERT(!PagePrivate(page));
if (!PageUptodate(page)) {
page_count--;
if (blocksize >= PAGE_CACHE_SIZE) {
Expand Down Expand Up @@ -768,7 +773,7 @@ xfs_buf_get_noaddr(
_xfs_buf_initialize(bp, target, 0, len, 0);

try_again:
data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL);
data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL | KM_LARGE);
if (unlikely(data == NULL))
goto fail_free_buf;

Expand Down Expand Up @@ -1117,10 +1122,10 @@ xfs_buf_bio_end_io(
do {
struct page *page = bvec->bv_page;

ASSERT(!PagePrivate(page));
if (unlikely(bp->b_error)) {
if (bp->b_flags & XBF_READ)
ClearPageUptodate(page);
SetPageError(page);
} else if (blocksize >= PAGE_CACHE_SIZE) {
SetPageUptodate(page);
} else if (!PagePrivate(page) &&
Expand Down Expand Up @@ -1156,16 +1161,16 @@ _xfs_buf_ioapply(
total_nr_pages = bp->b_page_count;
map_i = 0;

if (bp->b_flags & _XBF_RUN_QUEUES) {
bp->b_flags &= ~_XBF_RUN_QUEUES;
rw = (bp->b_flags & XBF_READ) ? READ_SYNC : WRITE_SYNC;
} else {
rw = (bp->b_flags & XBF_READ) ? READ : WRITE;
}

if (bp->b_flags & XBF_ORDERED) {
ASSERT(!(bp->b_flags & XBF_READ));
rw = WRITE_BARRIER;
} else if (bp->b_flags & _XBF_RUN_QUEUES) {
ASSERT(!(bp->b_flags & XBF_READ_AHEAD));
bp->b_flags &= ~_XBF_RUN_QUEUES;
rw = (bp->b_flags & XBF_WRITE) ? WRITE_SYNC : READ_SYNC;
} else {
rw = (bp->b_flags & XBF_WRITE) ? WRITE :
(bp->b_flags & XBF_READ_AHEAD) ? READA : READ;
}

/* Special code path for reading a sub page size buffer in --
Expand Down Expand Up @@ -1681,6 +1686,7 @@ xfsbufd(
xfs_buf_t *bp, *n;
struct list_head *dwq = &target->bt_delwrite_queue;
spinlock_t *dwlk = &target->bt_delwrite_lock;
int count;

current->flags |= PF_MEMALLOC;

Expand All @@ -1696,6 +1702,7 @@ xfsbufd(
schedule_timeout_interruptible(
xfs_buf_timer_centisecs * msecs_to_jiffies(10));

count = 0;
age = xfs_buf_age_centisecs * msecs_to_jiffies(10);
spin_lock(dwlk);
list_for_each_entry_safe(bp, n, dwq, b_list) {
Expand All @@ -1711,9 +1718,11 @@ xfsbufd(
break;
}

bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q);
bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|
_XBF_RUN_QUEUES);
bp->b_flags |= XBF_WRITE;
list_move(&bp->b_list, &tmp);
list_move_tail(&bp->b_list, &tmp);
count++;
}
}
spin_unlock(dwlk);
Expand All @@ -1724,12 +1733,12 @@ xfsbufd(

list_del_init(&bp->b_list);
xfs_buf_iostrategy(bp);

blk_run_address_space(target->bt_mapping);
}

if (as_list_len > 0)
purge_addresses();
if (count)
blk_run_address_space(target->bt_mapping);

clear_bit(XBT_FORCE_FLUSH, &target->bt_flags);
} while (!kthread_should_stop());
Expand Down Expand Up @@ -1767,7 +1776,7 @@ xfs_flush_buftarg(
continue;
}

list_move(&bp->b_list, &tmp);
list_move_tail(&bp->b_list, &tmp);
}
spin_unlock(dwlk);

Expand All @@ -1776,7 +1785,7 @@ xfs_flush_buftarg(
*/
list_for_each_entry_safe(bp, n, &tmp, b_list) {
xfs_buf_lock(bp);
bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q);
bp->b_flags &= ~(XBF_DELWRI|_XBF_DELWRI_Q|_XBF_RUN_QUEUES);
bp->b_flags |= XBF_WRITE;
if (wait)
bp->b_flags &= ~XBF_ASYNC;
Expand All @@ -1786,6 +1795,9 @@ xfs_flush_buftarg(
xfs_buf_iostrategy(bp);
}

if (wait)
blk_run_address_space(target->bt_mapping);

/*
* Remaining list items must be flushed before returning
*/
Expand All @@ -1797,9 +1809,6 @@ xfs_flush_buftarg(
xfs_buf_relse(bp);
}

if (wait)
blk_run_address_space(target->bt_mapping);

return pincount;
}

Expand Down
7 changes: 0 additions & 7 deletions fs/xfs/linux-2.6/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *);
#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE)
#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE)

#define XFS_BUF_ISUNINITIAL(bp) (0)
#define XFS_BUF_UNUNINITIAL(bp) (0)

#define XFS_BUF_BP_ISMAPPED(bp) (1)

#define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone)
#define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func))
#define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL)
Expand Down Expand Up @@ -393,8 +388,6 @@ static inline int XFS_bwrite(xfs_buf_t *bp)
return error;
}

#define XFS_bdwrite(bp) xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC)

static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp)
{
bp->b_strat = xfs_bdstrat_cb;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ xfs_param_t xfs_params = {
.restrict_chown = { 0, 1, 1 },
.sgid_inherit = { 0, 0, 1 },
.symlink_mode = { 0, 0, 1 },
.panic_mask = { 0, 0, 127 },
.panic_mask = { 0, 0, 255 },
.error_level = { 0, 3, 11 },
.syncd_timer = { 1*100, 30*100, 7200*100},
.stats_clear = { 0, 0, 1 },
Expand Down
19 changes: 7 additions & 12 deletions fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ xfs_attrmulti_by_handle(
STATIC int
xfs_ioc_space(
bhv_desc_t *bdp,
bhv_vnode_t *vp,
struct inode *inode,
struct file *filp,
int flags,
unsigned int cmd,
Expand Down Expand Up @@ -735,7 +735,7 @@ xfs_ioctl(
!capable(CAP_SYS_ADMIN))
return -EPERM;

return xfs_ioc_space(bdp, vp, filp, ioflags, cmd, arg);
return xfs_ioc_space(bdp, inode, filp, ioflags, cmd, arg);

case XFS_IOC_DIOINFO: {
struct dioattr da;
Expand Down Expand Up @@ -763,6 +763,8 @@ xfs_ioctl(
return xfs_ioc_fsgeometry(mp, arg);

case XFS_IOC_GETVERSION:
return put_user(inode->i_generation, (int __user *)arg);

case XFS_IOC_GETXFLAGS:
case XFS_IOC_SETXFLAGS:
case XFS_IOC_FSGETXATTR:
Expand Down Expand Up @@ -957,7 +959,7 @@ xfs_ioctl(
STATIC int
xfs_ioc_space(
bhv_desc_t *bdp,
bhv_vnode_t *vp,
struct inode *inode,
struct file *filp,
int ioflags,
unsigned int cmd,
Expand All @@ -967,13 +969,13 @@ xfs_ioc_space(
int attr_flags = 0;
int error;

if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
if (inode->i_flags & (S_IMMUTABLE|S_APPEND))
return -XFS_ERROR(EPERM);

if (!(filp->f_mode & FMODE_WRITE))
return -XFS_ERROR(EBADF);

if (!VN_ISREG(vp))
if (!S_ISREG(inode->i_mode))
return -XFS_ERROR(EINVAL);

if (copy_from_user(&bf, arg, sizeof(bf)))
Expand Down Expand Up @@ -1264,13 +1266,6 @@ xfs_ioc_xattr(
break;
}

case XFS_IOC_GETVERSION: {
flags = vn_to_inode(vp)->i_generation;
if (copy_to_user(arg, &flags, sizeof(flags)))
error = -EFAULT;
break;
}

default:
error = -ENOTTY;
break;
Expand Down
Loading

0 comments on commit c0341b0

Please sign in to comment.