Commit c5df32b4 authored by Christoph Hellwig's avatar Christoph Hellwig

Merge

parents f01d7733 697d719c
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......@@ -48,8 +48,11 @@ linvfs_unwritten_done(
clear_buffer_unwritten(bh);
if (!uptodate)
pagebuf_ioerror(pb, -EIO);
if (atomic_dec_and_test(&pb->pb_io_remaining) == 1)
if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
pagebuf_iodone(pb, 1, 1);
pb->pb_flags &= ~_PBF_LOCKABLE;
pagebuf_rele(pb);
}
end_buffer_async_write(bh, uptodate);
}
......@@ -160,7 +163,7 @@ map_buffer_at_offset(
delta -= mp->pbm_offset;
delta >>= block_bits;
sector_shift = block_bits - 9;
sector_shift = block_bits - BBSHIFT;
bn = mp->pbm_bn >> sector_shift;
bn += delta;
ASSERT((bn << sector_shift) >= mp->pbm_bn);
......@@ -282,7 +285,7 @@ probe_unmapped_cluster(
total += bh->b_size;
} while ((bh = bh->b_this_page) != head);
/* if we reached the end of the page, sum forwards in
/* If we reached the end of the page, sum forwards in
* following pages.
*/
if (bh == head) {
......@@ -438,8 +441,11 @@ map_unwritten(
XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode)->v_fbhv);
XFS_BUF_SET_IODONE_FUNC(pb, xfs_unwritten_conv);
if (atomic_dec_and_test(&pb->pb_io_remaining) == 1)
if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
pagebuf_iodone(pb, 1, 1);
pb->pb_flags &= ~_PBF_LOCKABLE;
pagebuf_rele(pb);
}
return 0;
}
......@@ -729,8 +735,8 @@ page_state_convert(
page_dirty = 0;
}
} else if (startio) {
if (buffer_uptodate(bh)) {
lock_buffer(bh);
if (buffer_uptodate(bh) &&
!test_and_set_bit(BH_Lock, &bh->b_state)) {
bh_arr[cnt++] = bh;
page_dirty = 0;
}
......@@ -753,8 +759,7 @@ page_state_convert(
}
if (mp) {
cluster_write(inode, page->index + 1, mp,
startio, unmapped);
cluster_write(inode, page->index + 1, mp, startio, unmapped);
}
return page_dirty;
......@@ -763,7 +768,7 @@ page_state_convert(
for (i = 0; i < cnt; i++) {
unlock_buffer(bh_arr[i]);
}
/*
* If it's delalloc and we have nowhere to put it,
* throw it away, unless the lower layers told
......@@ -806,8 +811,7 @@ linvfs_get_block_core(
size = 1 << inode->i_blkbits;
VOP_BMAP(vp, offset, size,
create ? flags : PBF_READ,
(struct page_buf_bmap_s *)&pbmap, &retpbbm, error);
create ? flags : PBF_READ, &pbmap, &retpbbm, error);
if (error)
return -error;
......@@ -825,7 +829,7 @@ linvfs_get_block_core(
delta = offset - pbmap.pbm_offset;
delta >>= inode->i_blkbits;
bn = pbmap.pbm_bn >> (inode->i_blkbits - 9);
bn = pbmap.pbm_bn >> (inode->i_blkbits - BBSHIFT);
bn += delta;
bh_result->b_blocknr = bn;
......
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......@@ -136,6 +136,7 @@ linvfs_aio_write(
return linvfs_writev(iocb->ki_filp, &iov, 1, &iocb->ki_pos);
}
STATIC ssize_t
linvfs_sendfile(
struct file *filp,
......@@ -199,9 +200,7 @@ linvfs_fsync(
flags |= FSYNC_DATA;
ASSERT(vp);
VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
return -error;
}
......@@ -288,6 +287,7 @@ linvfs_readdir(
return -error;
}
STATIC int
linvfs_file_mmap(
struct file *filp,
......
......@@ -48,11 +48,6 @@ unsigned long xfs_physmem;
*/
xfs_param_t xfs_params = { 0, 1, 0, 0, 0, 3 };
/*
* Used to serialize atomicIncWithWrap.
*/
spinlock_t xfs_atomic_spin = SPIN_LOCK_UNLOCKED;
/*
* Global system credential structure.
*/
......
......@@ -38,11 +38,7 @@
*/
extern uint64_t xfs_panic_mask; /* set to cause more panics */
extern unsigned long xfs_physmem;
extern spinlock_t xfs_atomic_spin;
extern struct cred *sys_cred;
#endif /* __XFS_GLOBALS_H__ */
......@@ -39,11 +39,6 @@
#include <linux/pagemap.h>
extern int xfs_change_file_space(bhv_desc_t *, int,
xfs_flock64_t *, xfs_off_t, cred_t *, int);
extern int xfs_set_dmattrs(bhv_desc_t *, u_int, u_int16_t, cred_t *);
/*
* xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
* a file or fs handle.
......
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......
......@@ -257,7 +257,7 @@ xfs_showargs(
};
struct proc_xfs_info *xfs_infop;
struct xfs_mount *mp = XFS_BHVTOM(bhv);
char b[BDEVNAME_SIZE];
char b[BDEVNAME_SIZE];
for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
if (mp->m_flags & xfs_infop->flag)
......
/*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
#ifndef __XFS_SUPPORT_ATOMIC_H__
#define __XFS_SUPPORT_ATOMIC_H__
#include <linux/version.h>
#include <linux/time.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <asm/atomic.h>
#include <asm/semaphore.h>
/*
* This is used for two variables in XFS, one of which is a debug trace
* buffer index. They are not accessed via any other atomic operations
* so this is safe. All other atomic increments and decrements in XFS
* now use the Linux built-in functions.
*/
extern spinlock_t xfs_atomic_spin;
static __inline__ int atomicIncWithWrap(int *ip, int val)
{
unsigned long flags;
int ret;
spin_lock_irqsave(&xfs_atomic_spin, flags);
ret = *ip;
(*ip)++;
if (*ip == val) *ip = 0;
spin_unlock_irqrestore(&xfs_atomic_spin, flags);
return ret;
}
#endif /* __XFS_SUPPORT_ATOMIC_H__ */
......@@ -37,7 +37,6 @@
#include "kmem.h"
#include "spin.h"
#include "debug.h"
#include "atomic.h"
#include "ktrace.h"
#if (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
......@@ -181,6 +180,7 @@ ktrace_enter(
void *val14,
void *val15)
{
static lock_t wrap_lock = SPIN_LOCK_UNLOCKED;
int index;
ktrace_entry_t *ktep;
......@@ -189,7 +189,11 @@ ktrace_enter(
/*
* Grab an entry by pushing the index up to the next one.
*/
index = atomicIncWithWrap(&ktp->kt_index, ktp->kt_nentries);
spin_lock(&wrap_lock);
index = ktp->kt_index;
if (++ktp->kt_index == ktp->kt_nentries)
ktp->kt_index = 0;
spin_unlock(&wrap_lock);
if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
ktp->kt_rollover = 1;
......
......@@ -46,7 +46,6 @@
#include <support/ktrace.h>
#include <support/mutex.h>
#include <support/sema.h>
#include <support/atomic.h>
#include <support/debug.h>
#include <support/move.h>
#include <support/uuid.h>
......
......@@ -459,6 +459,8 @@ int xfs_bmap_sanity_check(struct xfs_mount *mp, xfs_bmbt_block_t *bb,
#endif
#ifdef __KERNEL__
/*
* Prototypes for xfs_bmap.c to call.
*/
......@@ -706,5 +708,6 @@ xfs_bmap_do_search_extents(
xfs_bmbt_irec_t *,
xfs_bmbt_irec_t *);
#endif /* __KERNEL__ */
#endif /* __XFS_BMAP_BTREE_H__ */
......@@ -186,7 +186,7 @@ typedef enum {
extern struct bhv_vfsops xfs_dmops;
extern void xfs_dm_init(void);
extern void xfs_dm_exit(void);
extern int dmapi_init(void);
extern void dmapi_uninit(void);
#endif /* __XFS_DMAPI_H__ */
/*
* Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 1995-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License
......@@ -44,21 +44,25 @@
* d_miniosz is the min xfer size, xfer size multiple and file seek offset
* alignment.
*/
#ifndef HAVE_DIOATTR
struct dioattr {
__u32 d_mem; /* data buffer memory alignment */
__u32 d_miniosz; /* min xfer size */
__u32 d_maxiosz; /* max xfer size */
};
#endif
/*
* Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR.
*/
#ifndef HAVE_FSXATTR
struct fsxattr {
__u32 fsx_xflags; /* xflags field value (get/set) */
__u32 fsx_extsize; /* extsize field value (get/set)*/
__u32 fsx_nextents; /* nextents field value (get) */
unsigned char fsx_pad[16];
};
#endif
/*
* Flags for the bs_xflags/fsx_xflags field
......@@ -79,6 +83,7 @@ struct fsxattr {
* number of array elements given. The first structure is updated on
* return to give the offset and length for the next call.
*/
#ifndef HAVE_GETBMAP
struct getbmap {
__s64 bmv_offset; /* file offset of segment in blocks */
__s64 bmv_block; /* starting block (64-bit daddr_t) */
......@@ -86,6 +91,7 @@ struct getbmap {
__s32 bmv_count; /* # of entries in array incl. 1st */
__s32 bmv_entries; /* # of entries filled in (output) */
};
#endif
/*
* Structure for XFS_IOC_GETBMAPX. Fields bmv_offset through bmv_entries
......@@ -96,6 +102,7 @@ struct getbmap {
* in by the XFS_IOC_GETBMAPX command for each returned structure after
* the first.
*/
#ifndef HAVE_GETBMAPX
struct getbmapx {
__s64 bmv_offset; /* file offset of segment in blocks */
__s64 bmv_block; /* starting block (64-bit daddr_t) */
......@@ -107,6 +114,7 @@ struct getbmapx {
__s32 bmv_unused1; /* future use */
__s32 bmv_unused2; /* future use */
};
#endif
/* bmv_iflags values - set by XFS_IOC_GETBMAPX caller. */
#define BMV_IF_ATTRFORK 0x1 /* return attr fork rather than data */
......@@ -136,11 +144,13 @@ struct getbmapx {
* only values previously obtained via xfs_bulkstat! (Specifically the
* xfs_bstat_t fields bs_dmevmask and bs_dmstate.)
*/
#ifndef HAVE_FSDMIDATA
struct fsdmidata {
__u32 fsd_dmevmask; /* corresponds to di_dmevmask */
__u16 fsd_padding;
__u16 fsd_dmstate; /* corresponds to di_dmstate */
};
#endif
/*
* File segment locking set data type for 64 bit access.
......@@ -391,7 +401,7 @@ typedef struct {
* This is typically called by a stateless file server in order to generate
* "file handles".
*/
#ifndef MAXFIDSZ
#ifndef HAVE_FID
#define MAXFIDSZ 46
typedef struct fid {
__u16 fid_len; /* length of data in bytes */
......@@ -472,7 +482,7 @@ typedef struct xfs_handle {
#define XFS_IOC_FSGROWFSLOG _IOW ('X', 111, struct xfs_growfs_log)
#define XFS_IOC_FSGROWFSRT _IOW ('X', 112, struct xfs_growfs_rt)
#define XFS_IOC_FSCOUNTS _IOR ('X', 113, struct xfs_fsop_counts)
#define XFS_IOC_SET_RESBLKS _IOR ('X', 114, struct xfs_fsop_resblks)
#define XFS_IOC_SET_RESBLKS _IOWR('X', 114, struct xfs_fsop_resblks)
#define XFS_IOC_GET_RESBLKS _IOR ('X', 115, struct xfs_fsop_resblks)
#define XFS_IOC_ERROR_INJECTION _IOW ('X', 116, struct xfs_error_injection)
#define XFS_IOC_ERROR_CLEARALL _IOW ('X', 117, struct xfs_error_injection)
......@@ -486,6 +496,7 @@ typedef struct xfs_handle {
/* XFS_IOC_GETFSUUID ---------- deprecated 140 */
#ifndef HAVE_BBMACROS
/*
* Block I/O parameterization. A basic block (BB) is the lowest size of
* filesystem allocation, and must equal 512. Length units given to bio
......@@ -497,5 +508,6 @@ typedef struct xfs_handle {
#define BTOBB(bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT)
#define BTOBBT(bytes) ((__u64)(bytes) >> BBSHIFT)
#define BBTOB(bbs) ((bbs) << BBSHIFT)
#endif
#endif /* __XFS_FS_H__ */
......@@ -336,6 +336,21 @@ xfs_ialloc_ag_alloc(
return 0;
}
STATIC __inline xfs_agnumber_t
xfs_ialloc_next_ag(
xfs_mount_t *mp)
{
xfs_agnumber_t agno;
spin_lock(&mp->m_agirotor_lock);
agno = mp->m_agirotor;
if (++mp->m_agirotor == mp->m_maxagi)
mp->m_agirotor = 0;
spin_unlock(&mp->m_agirotor_lock);
return agno;
}
/*
* Select an allocation group to look for a free inode in, based on the parent
* inode and then mode. Return the allocation group buffer.
......@@ -366,7 +381,7 @@ xfs_ialloc_ag_select(
mp = tp->t_mountp;
agcount = mp->m_maxagi;
if (S_ISDIR(mode))
pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
pagno = xfs_ialloc_next_ag(mp);
else {
pagno = XFS_INO_TO_AGNO(mp, parent);
if (pagno >= agcount)
......@@ -394,7 +409,7 @@ xfs_ialloc_ag_select(
agbp = NULL;
if (!pag->pagi_inodeok) {
atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
xfs_ialloc_next_ag(mp);
goto unlock_nextag;
}
......
/*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
......
......@@ -3608,31 +3608,6 @@ xfs_ichgtime(xfs_inode_t *ip,
ip->i_update_core = 1;
}
/*
* xfs_ibusy_check -- Checks whether inode reference count allows unmount
*
* The value returned is one if the reference count would prevent an unmount.
*/
int
xfs_ibusy_check(
xfs_inode_t *ip,
int refs)
{
xfs_mount_t *mp = ip->i_mount;
if ((refs == 1) && (ip == mp->m_rootip))
return (0);
if ((refs == 1) && (ip == mp->m_rbmip))
return (0);
if ((refs == 1) && (ip == mp->m_rsumip))
return (0);
if (mp->m_quotainfo && ip->i_ino == mp->m_sb.sb_uquotino)
return (0);
if (mp->m_quotainfo && ip->i_ino == mp->m_sb.sb_gquotino)
return (0);
return (1);
}
#ifdef XFS_ILOCK_TRACE
void
xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
......
......@@ -516,7 +516,6 @@ void xfs_iunpin(xfs_inode_t *);
int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int);
int xfs_iflush(xfs_inode_t *, uint);
int xfs_iflush_all(struct xfs_mount *, int);
int xfs_ibusy_check(xfs_inode_t *, int);
int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *);
uint xfs_iroundup(uint);
void xfs_ichgtime(xfs_inode_t *, int);
......
......@@ -509,6 +509,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
int i;
mp->m_agfrotor = mp->m_agirotor = 0;
spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock");
mp->m_maxagi = mp->m_sb.sb_agcount;
mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
......
......@@ -291,6 +291,7 @@ typedef struct xfs_mount {
int m_bsize; /* fs logical block size */
xfs_agnumber_t m_agfrotor; /* last ag where space found */
xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
lock_t m_agirotor_lock;/* .. and lock protecting it */
xfs_agnumber_t m_maxagi; /* highest inode alloc group */
int m_ihsize; /* size of next field */
struct xfs_ihash *m_ihash; /* fs private inode hash table*/
......
......@@ -153,39 +153,55 @@ int
xfs_bioerror(
struct xfs_buf *b);
/*
* XFS I/O core functions
*/
extern int xfs_bioerror_relse(struct xfs_buf *);
int
xfs_bioerror_relse(
struct xfs_buf *b);
int
xfs_read_buf(
struct xfs_mount *mp,
xfs_buftarg_t *target,
xfs_daddr_t blkno,
int len,
uint flags,
struct xfs_buf **bpp);
void
xfs_ioerror_alert(
char *func,
struct xfs_mount *mp,
xfs_buf_t *bp,
xfs_daddr_t blkno);
/*
* Needed by xfs_rw.c
* Prototypes for functions in xfs_vnodeops.c.
*/
int
xfs_rwlock(
bhv_desc_t *bdp,
vrwlock_t write_lock);
bhv_desc_t *bdp,
vrwlock_t write_lock);
void
xfs_rwunlock(
bhv_desc_t *bdp,
vrwlock_t write_lock);
bhv_desc_t *bdp,
vrwlock_t write_lock);
int
xfs_read_buf(
struct xfs_mount *mp,
xfs_buftarg_t *target,
xfs_daddr_t blkno,
int len,
uint flags,
struct xfs_buf **bpp);
xfs_change_file_space(
bhv_desc_t *bdp,
int cmd,
xfs_flock64_t *bf,
xfs_off_t offset,
cred_t *credp,
int flags);
void
xfs_ioerror_alert(
char *func,
struct xfs_mount *mp,
xfs_buf_t *bp,
xfs_daddr_t blkno);
int
xfs_set_dmattrs(
bhv_desc_t *bdp,
u_int evmask,
u_int16_t state,
cred_t *credp);
#endif /* __XFS_RW_H__ */
......@@ -34,9 +34,7 @@
#include <xfs.h>
STATIC int xfs_ibusy(xfs_mount_t *);
STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
STATIC int xfs_unmount(bhv_desc_t *, int, cred_t *);
int
xfs_init(void)
......@@ -485,59 +483,6 @@ xfs_mount(
return error;
}
/*
* xfs_ibusy searches for a busy inode in the mounted file system.
*
* Return 0 if there are no active inodes otherwise return 1.
*/
STATIC int
xfs_ibusy(
xfs_mount_t *mp)
{
xfs_inode_t *ip;
vnode_t *vp;
int busy;
busy = 0;
XFS_MOUNT_ILOCK(mp);
ip = mp->m_inodes;
if (ip == NULL) {
XFS_MOUNT_IUNLOCK(mp);
return busy;
}
do {
/* Skip markers inserted by xfs_sync */
if (ip->i_mount == NULL) {
ip = ip->i_mnext;
continue;
}
vp = XFS_ITOV_NULL(ip);
if (vp && vn_count(vp) != 0) {
if (xfs_ibusy_check(ip, vn_count(vp)) == 0) {
ip = ip->i_mnext;
continue;
}
#ifdef DEBUG
cmn_err(CE_WARN, "%s: busy vp=0x%p ip=0x%p "
"inum %Ld count=%d",
__FUNCTION__, vp, ip, ip->i_ino, vn_count(vp));
#endif
busy++;
}
ip = ip->i_mnext;
} while ((ip != mp->m_inodes) && !busy);
XFS_MOUNT_IUNLOCK(mp);
return busy;
}
STATIC int
xfs_unmount(
bhv_desc_t *bdp,
......@@ -572,16 +517,6 @@ xfs_unmount(
0 : DM_FLAGS_UNWANTED;
}
/*
* Make sure there are no active users.
*/
if (xfs_ibusy(mp)) {
error = XFS_ERROR(EBUSY);
cmn_err(CE_ALERT, "%s: xfs_ibusy failed -- error code %d",
__FUNCTION__, error);
goto out;
}
XFS_bflush(mp->m_ddev_targp);
error = xfs_unmount_flush(mp, 0);
if (error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment