Commit 4d9d4ebf authored by Lachlan McIlroy's avatar Lachlan McIlroy

Merge branch 'master' of git+ssh://git.melbourne.sgi.com/git/xfs

parents cfbe5267 c4cd747e
...@@ -1085,7 +1085,7 @@ xfs_bawrite( ...@@ -1085,7 +1085,7 @@ xfs_bawrite(
bp->b_flags &= ~(XBF_READ | XBF_DELWRI | XBF_READ_AHEAD); bp->b_flags &= ~(XBF_READ | XBF_DELWRI | XBF_READ_AHEAD);
bp->b_flags |= (XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES); bp->b_flags |= (XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES);
bp->b_fspriv3 = mp; bp->b_mount = mp;
bp->b_strat = xfs_bdstrat_cb; bp->b_strat = xfs_bdstrat_cb;
return xfs_bdstrat_cb(bp); return xfs_bdstrat_cb(bp);
} }
...@@ -1098,7 +1098,7 @@ xfs_bdwrite( ...@@ -1098,7 +1098,7 @@ xfs_bdwrite(
XB_TRACE(bp, "bdwrite", 0); XB_TRACE(bp, "bdwrite", 0);
bp->b_strat = xfs_bdstrat_cb; bp->b_strat = xfs_bdstrat_cb;
bp->b_fspriv3 = mp; bp->b_mount = mp;
bp->b_flags &= ~XBF_READ; bp->b_flags &= ~XBF_READ;
bp->b_flags |= (XBF_DELWRI | XBF_ASYNC); bp->b_flags |= (XBF_DELWRI | XBF_ASYNC);
......
...@@ -168,7 +168,7 @@ typedef struct xfs_buf { ...@@ -168,7 +168,7 @@ typedef struct xfs_buf {
struct completion b_iowait; /* queue for I/O waiters */ struct completion b_iowait; /* queue for I/O waiters */
void *b_fspriv; void *b_fspriv;
void *b_fspriv2; void *b_fspriv2;
void *b_fspriv3; struct xfs_mount *b_mount;
unsigned short b_error; /* error code on I/O */ unsigned short b_error; /* error code on I/O */
unsigned int b_page_count; /* size of page array */ unsigned int b_page_count; /* size of page array */
unsigned int b_offset; /* page offset in first page */ unsigned int b_offset; /* page offset in first page */
...@@ -335,8 +335,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *); ...@@ -335,8 +335,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *);
#define XFS_BUF_SET_FSPRIVATE(bp, val) ((bp)->b_fspriv = (void*)(val)) #define XFS_BUF_SET_FSPRIVATE(bp, val) ((bp)->b_fspriv = (void*)(val))
#define XFS_BUF_FSPRIVATE2(bp, type) ((type)(bp)->b_fspriv2) #define XFS_BUF_FSPRIVATE2(bp, type) ((type)(bp)->b_fspriv2)
#define XFS_BUF_SET_FSPRIVATE2(bp, val) ((bp)->b_fspriv2 = (void*)(val)) #define XFS_BUF_SET_FSPRIVATE2(bp, val) ((bp)->b_fspriv2 = (void*)(val))
#define XFS_BUF_FSPRIVATE3(bp, type) ((type)(bp)->b_fspriv3)
#define XFS_BUF_SET_FSPRIVATE3(bp, val) ((bp)->b_fspriv3 = (void*)(val))
#define XFS_BUF_SET_START(bp) do { } while (0) #define XFS_BUF_SET_START(bp) do { } while (0)
#define XFS_BUF_SET_BRELSE_FUNC(bp, func) ((bp)->b_relse = (func)) #define XFS_BUF_SET_BRELSE_FUNC(bp, func) ((bp)->b_relse = (func))
......
...@@ -45,80 +45,44 @@ ...@@ -45,80 +45,44 @@
static struct vm_operations_struct xfs_file_vm_ops; static struct vm_operations_struct xfs_file_vm_ops;
STATIC_INLINE ssize_t STATIC ssize_t
__xfs_file_read( xfs_file_aio_read(
struct kiocb *iocb, struct kiocb *iocb,
const struct iovec *iov, const struct iovec *iov,
unsigned long nr_segs, unsigned long nr_segs,
int ioflags,
loff_t pos) loff_t pos)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
int ioflags = IO_ISAIO;
BUG_ON(iocb->ki_pos != pos); BUG_ON(iocb->ki_pos != pos);
if (unlikely(file->f_flags & O_DIRECT)) if (unlikely(file->f_flags & O_DIRECT))
ioflags |= IO_ISDIRECT; ioflags |= IO_ISDIRECT;
if (file->f_mode & FMODE_NOCMTIME)
ioflags |= IO_INVIS;
return xfs_read(XFS_I(file->f_path.dentry->d_inode), iocb, iov, return xfs_read(XFS_I(file->f_path.dentry->d_inode), iocb, iov,
nr_segs, &iocb->ki_pos, ioflags); nr_segs, &iocb->ki_pos, ioflags);
} }
STATIC ssize_t STATIC ssize_t
xfs_file_aio_read( xfs_file_aio_write(
struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs,
loff_t pos)
{
return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO, pos);
}
STATIC ssize_t
xfs_file_aio_read_invis(
struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs,
loff_t pos)
{
return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos);
}
STATIC_INLINE ssize_t
__xfs_file_write(
struct kiocb *iocb, struct kiocb *iocb,
const struct iovec *iov, const struct iovec *iov,
unsigned long nr_segs, unsigned long nr_segs,
int ioflags,
loff_t pos) loff_t pos)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
int ioflags = IO_ISAIO;
BUG_ON(iocb->ki_pos != pos); BUG_ON(iocb->ki_pos != pos);
if (unlikely(file->f_flags & O_DIRECT)) if (unlikely(file->f_flags & O_DIRECT))
ioflags |= IO_ISDIRECT; ioflags |= IO_ISDIRECT;
if (file->f_mode & FMODE_NOCMTIME)
ioflags |= IO_INVIS;
return xfs_write(XFS_I(file->f_mapping->host), iocb, iov, nr_segs, return xfs_write(XFS_I(file->f_mapping->host), iocb, iov, nr_segs,
&iocb->ki_pos, ioflags); &iocb->ki_pos, ioflags);
} }
STATIC ssize_t
xfs_file_aio_write(
struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs,
loff_t pos)
{
return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO, pos);
}
STATIC ssize_t
xfs_file_aio_write_invis(
struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs,
loff_t pos)
{
return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos);
}
STATIC ssize_t STATIC ssize_t
xfs_file_splice_read( xfs_file_splice_read(
struct file *infilp, struct file *infilp,
...@@ -127,20 +91,13 @@ xfs_file_splice_read( ...@@ -127,20 +91,13 @@ xfs_file_splice_read(
size_t len, size_t len,
unsigned int flags) unsigned int flags)
{ {
return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode), int ioflags = 0;
infilp, ppos, pipe, len, flags, 0);
} if (infilp->f_mode & FMODE_NOCMTIME)
ioflags |= IO_INVIS;
STATIC ssize_t
xfs_file_splice_read_invis(
struct file *infilp,
loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len,
unsigned int flags)
{
return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode), return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode),
infilp, ppos, pipe, len, flags, IO_INVIS); infilp, ppos, pipe, len, flags, ioflags);
} }
STATIC ssize_t STATIC ssize_t
...@@ -151,20 +108,13 @@ xfs_file_splice_write( ...@@ -151,20 +108,13 @@ xfs_file_splice_write(
size_t len, size_t len,
unsigned int flags) unsigned int flags)
{ {
return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode), int ioflags = 0;
pipe, outfilp, ppos, len, flags, 0);
} if (outfilp->f_mode & FMODE_NOCMTIME)
ioflags |= IO_INVIS;
STATIC ssize_t
xfs_file_splice_write_invis(
struct pipe_inode_info *pipe,
struct file *outfilp,
loff_t *ppos,
size_t len,
unsigned int flags)
{
return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode), return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode),
pipe, outfilp, ppos, len, flags, IO_INVIS); pipe, outfilp, ppos, len, flags, ioflags);
} }
STATIC int STATIC int
...@@ -275,42 +225,6 @@ xfs_file_mmap( ...@@ -275,42 +225,6 @@ xfs_file_mmap(
return 0; return 0;
} }
STATIC long
xfs_file_ioctl(
struct file *filp,
unsigned int cmd,
unsigned long p)
{
struct inode *inode = filp->f_path.dentry->d_inode;
/* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as
* readlink_by_handle. So we don't "sign flip"
* like most other routines. This means true
* errors need to be returned as a negative value.
*/
return xfs_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p);
}
STATIC long
xfs_file_ioctl_invis(
struct file *filp,
unsigned int cmd,
unsigned long p)
{
struct inode *inode = filp->f_path.dentry->d_inode;
/* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as
* readlink_by_handle. So we don't "sign flip"
* like most other routines. This means true
* errors need to be returned as a negative value.
*/
return xfs_ioctl(XFS_I(inode), filp, IO_INVIS, cmd, (void __user *)p);
}
/* /*
* mmap()d file has taken write protection fault and is being made * mmap()d file has taken write protection fault and is being made
* writable. We can set the page state up correctly for a writable * writable. We can set the page state up correctly for a writable
...@@ -346,25 +260,6 @@ const struct file_operations xfs_file_operations = { ...@@ -346,25 +260,6 @@ const struct file_operations xfs_file_operations = {
#endif #endif
}; };
const struct file_operations xfs_invis_file_operations = {
.llseek = generic_file_llseek,
.read = do_sync_read,
.write = do_sync_write,
.aio_read = xfs_file_aio_read_invis,
.aio_write = xfs_file_aio_write_invis,
.splice_read = xfs_file_splice_read_invis,
.splice_write = xfs_file_splice_write_invis,
.unlocked_ioctl = xfs_file_ioctl_invis,
#ifdef CONFIG_COMPAT
.compat_ioctl = xfs_file_compat_invis_ioctl,
#endif
.mmap = xfs_file_mmap,
.open = xfs_file_open,
.release = xfs_file_release,
.fsync = xfs_file_fsync,
};
const struct file_operations xfs_dir_file_operations = { const struct file_operations xfs_dir_file_operations = {
.open = xfs_dir_open, .open = xfs_dir_open,
.read = generic_read_dir, .read = generic_read_dir,
......
...@@ -319,10 +319,11 @@ xfs_open_by_handle( ...@@ -319,10 +319,11 @@ xfs_open_by_handle(
put_unused_fd(new_fd); put_unused_fd(new_fd);
return -XFS_ERROR(-PTR_ERR(filp)); return -XFS_ERROR(-PTR_ERR(filp));
} }
if (inode->i_mode & S_IFREG) { if (inode->i_mode & S_IFREG) {
/* invisible operation should not change atime */ /* invisible operation should not change atime */
filp->f_flags |= O_NOATIME; filp->f_flags |= O_NOATIME;
filp->f_op = &xfs_invis_file_operations; filp->f_mode |= FMODE_NOCMTIME;
} }
fd_install(new_fd, filp); fd_install(new_fd, filp);
...@@ -1328,21 +1329,31 @@ xfs_ioc_getbmapx( ...@@ -1328,21 +1329,31 @@ xfs_ioc_getbmapx(
return 0; return 0;
} }
int /*
xfs_ioctl( * Note: some of the ioctl's return positive numbers as a
xfs_inode_t *ip, * byte count indicating success, such as readlink_by_handle.
* So we don't "sign flip" like most other routines. This means
* true errors need to be returned as a negative value.
*/
long
xfs_file_ioctl(
struct file *filp, struct file *filp,
int ioflags,
unsigned int cmd, unsigned int cmd,
void __user *arg) unsigned long p)
{ {
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
xfs_mount_t *mp = ip->i_mount; struct xfs_inode *ip = XFS_I(inode);
struct xfs_mount *mp = ip->i_mount;
void __user *arg = (void __user *)p;
int ioflags = 0;
int error; int error;
xfs_itrace_entry(XFS_I(inode)); if (filp->f_mode & FMODE_NOCMTIME)
switch (cmd) { ioflags |= IO_INVIS;
xfs_itrace_entry(ip);
switch (cmd) {
case XFS_IOC_ALLOCSP: case XFS_IOC_ALLOCSP:
case XFS_IOC_FREESP: case XFS_IOC_FREESP:
case XFS_IOC_RESVSP: case XFS_IOC_RESVSP:
......
...@@ -68,13 +68,13 @@ xfs_attrmulti_attr_remove( ...@@ -68,13 +68,13 @@ xfs_attrmulti_attr_remove(
__uint32_t flags); __uint32_t flags);
extern long extern long
xfs_file_compat_ioctl( xfs_file_ioctl(
struct file *file, struct file *filp,
unsigned int cmd, unsigned int cmd,
unsigned long arg); unsigned long p);
extern long extern long
xfs_file_compat_invis_ioctl( xfs_file_compat_ioctl(
struct file *file, struct file *file,
unsigned int cmd, unsigned int cmd,
unsigned long arg); unsigned long arg);
......
...@@ -599,19 +599,24 @@ xfs_compat_fssetdm_by_handle( ...@@ -599,19 +599,24 @@ xfs_compat_fssetdm_by_handle(
return error; return error;
} }
STATIC long long
xfs_compat_ioctl( xfs_file_compat_ioctl(
xfs_inode_t *ip, struct file *filp,
struct file *filp, unsigned cmd,
int ioflags, unsigned long p)
unsigned cmd,
void __user *arg)
{ {
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
xfs_mount_t *mp = ip->i_mount; struct xfs_inode *ip = XFS_I(inode);
int error; struct xfs_mount *mp = ip->i_mount;
void __user *arg = (void __user *)p;
int ioflags = 0;
int error;
if (filp->f_mode & FMODE_NOCMTIME)
ioflags |= IO_INVIS;
xfs_itrace_entry(ip);
xfs_itrace_entry(XFS_I(inode));
switch (cmd) { switch (cmd) {
/* No size or alignment issues on any arch */ /* No size or alignment issues on any arch */
case XFS_IOC_DIOINFO: case XFS_IOC_DIOINFO:
...@@ -632,7 +637,7 @@ xfs_compat_ioctl( ...@@ -632,7 +637,7 @@ xfs_compat_ioctl(
case XFS_IOC_GOINGDOWN: case XFS_IOC_GOINGDOWN:
case XFS_IOC_ERROR_INJECTION: case XFS_IOC_ERROR_INJECTION:
case XFS_IOC_ERROR_CLEARALL: case XFS_IOC_ERROR_CLEARALL:
return xfs_ioctl(ip, filp, ioflags, cmd, arg); return xfs_file_ioctl(filp, cmd, p);
#ifndef BROKEN_X86_ALIGNMENT #ifndef BROKEN_X86_ALIGNMENT
/* These are handled fine if no alignment issues */ /* These are handled fine if no alignment issues */
case XFS_IOC_ALLOCSP: case XFS_IOC_ALLOCSP:
...@@ -646,7 +651,7 @@ xfs_compat_ioctl( ...@@ -646,7 +651,7 @@ xfs_compat_ioctl(
case XFS_IOC_FSGEOMETRY_V1: case XFS_IOC_FSGEOMETRY_V1:
case XFS_IOC_FSGROWFSDATA: case XFS_IOC_FSGROWFSDATA:
case XFS_IOC_FSGROWFSRT: case XFS_IOC_FSGROWFSRT:
return xfs_ioctl(ip, filp, ioflags, cmd, arg); return xfs_file_ioctl(filp, cmd, p);
#else #else
case XFS_IOC_ALLOCSP_32: case XFS_IOC_ALLOCSP_32:
case XFS_IOC_FREESP_32: case XFS_IOC_FREESP_32:
...@@ -687,7 +692,7 @@ xfs_compat_ioctl( ...@@ -687,7 +692,7 @@ xfs_compat_ioctl(
case XFS_IOC_SETXFLAGS_32: case XFS_IOC_SETXFLAGS_32:
case XFS_IOC_GETVERSION_32: case XFS_IOC_GETVERSION_32:
cmd = _NATIVE_IOC(cmd, long); cmd = _NATIVE_IOC(cmd, long);
return xfs_ioctl(ip, filp, ioflags, cmd, arg); return xfs_file_ioctl(filp, cmd, p);
case XFS_IOC_SWAPEXT: { case XFS_IOC_SWAPEXT: {
struct xfs_swapext sxp; struct xfs_swapext sxp;
struct compat_xfs_swapext __user *sxu = arg; struct compat_xfs_swapext __user *sxu = arg;
...@@ -738,26 +743,3 @@ xfs_compat_ioctl( ...@@ -738,26 +743,3 @@ xfs_compat_ioctl(
return -XFS_ERROR(ENOIOCTLCMD); return -XFS_ERROR(ENOIOCTLCMD);
} }
} }
long
xfs_file_compat_ioctl(
struct file *filp,
unsigned int cmd,
unsigned long p)
{
struct inode *inode = filp->f_path.dentry->d_inode;
return xfs_compat_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p);
}
long
xfs_file_compat_invis_ioctl(
struct file *filp,
unsigned int cmd,
unsigned long p)
{
struct inode *inode = filp->f_path.dentry->d_inode;
return xfs_compat_ioctl(XFS_I(inode), filp, IO_INVIS, cmd,
(void __user *)p);
}
...@@ -22,7 +22,6 @@ struct xfs_inode; ...@@ -22,7 +22,6 @@ struct xfs_inode;
extern const struct file_operations xfs_file_operations; extern const struct file_operations xfs_file_operations;
extern const struct file_operations xfs_dir_file_operations; extern const struct file_operations xfs_dir_file_operations;
extern const struct file_operations xfs_invis_file_operations;
extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size); extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
......
...@@ -847,13 +847,7 @@ xfs_write( ...@@ -847,13 +847,7 @@ xfs_write(
int int
xfs_bdstrat_cb(struct xfs_buf *bp) xfs_bdstrat_cb(struct xfs_buf *bp)
{ {
xfs_mount_t *mp; if (XFS_FORCED_SHUTDOWN(bp->b_mount)) {
mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *);
if (!XFS_FORCED_SHUTDOWN(mp)) {
xfs_buf_iorequest(bp);
return 0;
} else {
xfs_buftrace("XFS__BDSTRAT IOERROR", bp); xfs_buftrace("XFS__BDSTRAT IOERROR", bp);
/* /*
* Metadata write that didn't get logged but * Metadata write that didn't get logged but
...@@ -866,6 +860,9 @@ xfs_bdstrat_cb(struct xfs_buf *bp) ...@@ -866,6 +860,9 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
else else
return (xfs_bioerror(bp)); return (xfs_bioerror(bp));
} }
xfs_buf_iorequest(bp);
return 0;
} }
/* /*
......
...@@ -707,8 +707,8 @@ xfs_buf_item_init( ...@@ -707,8 +707,8 @@ xfs_buf_item_init(
* the first. If we do already have one, there is * the first. If we do already have one, there is
* nothing to do here so return. * nothing to do here so return.
*/ */
if (XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *) != mp) if (bp->b_mount != mp)
XFS_BUF_SET_FSPRIVATE3(bp, mp); bp->b_mount = mp;
XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb); XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) { if (XFS_BUF_FSPRIVATE(bp, void *) != NULL) {
lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *); lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
......
...@@ -870,7 +870,7 @@ xfs_iread( ...@@ -870,7 +870,7 @@ xfs_iread(
* around for a while. This helps to keep recently accessed * around for a while. This helps to keep recently accessed
* meta-data in-core longer. * meta-data in-core longer.
*/ */
XFS_BUF_SET_REF(bp, XFS_INO_REF); XFS_BUF_SET_REF(bp, XFS_INO_REF);
/* /*
* Use xfs_trans_brelse() to release the buffer containing the * Use xfs_trans_brelse() to release the buffer containing the
...@@ -3232,8 +3232,6 @@ xfs_iflush_int( ...@@ -3232,8 +3232,6 @@ xfs_iflush_int(
#ifdef XFS_ILOCK_TRACE #ifdef XFS_ILOCK_TRACE
ktrace_t *xfs_ilock_trace_buf;
void void
xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra) xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
{ {
......
...@@ -223,7 +223,6 @@ struct xfs_dquot; ...@@ -223,7 +223,6 @@ struct xfs_dquot;
#if defined(XFS_ILOCK_TRACE) #if defined(XFS_ILOCK_TRACE)
#define XFS_ILOCK_KTRACE_SIZE 32 #define XFS_ILOCK_KTRACE_SIZE 32
extern ktrace_t *xfs_ilock_trace_buf;
extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *); extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
#else #else
#define xfs_ilock_trace(i,n,f,ra) #define xfs_ilock_trace(i,n,f,ra)
...@@ -482,12 +481,6 @@ static inline void xfs_ifunlock(xfs_inode_t *ip) ...@@ -482,12 +481,6 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
(((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \
((pip)->i_d.di_mode & S_ISGID)) ((pip)->i_d.di_mode & S_ISGID))
/*
* Flags for xfs_iget()
*/
#define XFS_IGET_CREATE 0x1
#define XFS_IGET_BULKSTAT 0x2
/* /*
* xfs_iget.c prototypes. * xfs_iget.c prototypes.
*/ */
...@@ -509,8 +502,6 @@ void xfs_ireclaim(xfs_inode_t *); ...@@ -509,8 +502,6 @@ void xfs_ireclaim(xfs_inode_t *);
/* /*
* xfs_inode.c prototypes. * xfs_inode.c prototypes.
*/ */
int xfs_iread(struct xfs_mount *, struct xfs_trans *,
struct xfs_inode *, xfs_daddr_t, uint);
int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
int, struct xfs_buf **, boolean_t *, xfs_inode_t **); int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
...@@ -583,12 +574,20 @@ do { \ ...@@ -583,12 +574,20 @@ do { \
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
/*
* Flags for xfs_iget()
*/
#define XFS_IGET_CREATE 0x1
#define XFS_IGET_BULKSTAT 0x2
int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, int xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
xfs_ino_t, struct xfs_dinode **, xfs_ino_t, struct xfs_dinode **,
struct xfs_buf **, int *, uint); struct xfs_buf **, int *, uint);
int xfs_itobp(struct xfs_mount *, struct xfs_trans *, int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
struct xfs_inode *, struct xfs_dinode **, struct xfs_inode *, struct xfs_dinode **,
struct xfs_buf **, uint); struct xfs_buf **, uint);
int xfs_iread(struct xfs_mount *, struct xfs_trans *,
struct xfs_inode *, xfs_daddr_t, uint);
void xfs_dinode_from_disk(struct xfs_icdinode *, void xfs_dinode_from_disk(struct xfs_icdinode *,
struct xfs_dinode *); struct xfs_dinode *);
void xfs_dinode_to_disk(struct xfs_dinode *, void xfs_dinode_to_disk(struct xfs_dinode *,
......
...@@ -267,21 +267,16 @@ STATIC void ...@@ -267,21 +267,16 @@ STATIC void
xlog_recover_iodone( xlog_recover_iodone(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_mount_t *mp;
ASSERT(XFS_BUF_FSPRIVATE(bp, void *));
if (XFS_BUF_GETERROR(bp)) { if (XFS_BUF_GETERROR(bp)) {
/* /*
* We're not going to bother about retrying * We're not going to bother about retrying
* this during recovery. One strike! * this during recovery. One strike!
*/ */
mp = XFS_BUF_FSPRIVATE(bp, xfs_mount_t *);
xfs_ioerror_alert("xlog_recover_iodone", xfs_ioerror_alert("xlog_recover_iodone",
mp, bp, XFS_BUF_ADDR(bp)); bp->b_mount, bp, XFS_BUF_ADDR(bp));
xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); xfs_force_shutdown(bp->b_mount, SHUTDOWN_META_IO_ERROR);
} }
XFS_BUF_SET_FSPRIVATE(bp, NULL); bp->b_mount = NULL;
XFS_BUF_CLR_IODONE_FUNC(bp); XFS_BUF_CLR_IODONE_FUNC(bp);
xfs_biodone(bp); xfs_biodone(bp);
} }
...@@ -2225,9 +2220,8 @@ xlog_recover_do_buffer_trans( ...@@ -2225,9 +2220,8 @@ xlog_recover_do_buffer_trans(
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
error = xfs_bwrite(mp, bp); error = xfs_bwrite(mp, bp);
} else { } else {
ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL || ASSERT(bp->b_mount == NULL || bp->b_mount == mp);
XFS_BUF_FSPRIVATE(bp, xfs_mount_t *) == mp); bp->b_mount = mp;
XFS_BUF_SET_FSPRIVATE(bp, mp);
XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
xfs_bdwrite(mp, bp); xfs_bdwrite(mp, bp);
} }
...@@ -2490,9 +2484,8 @@ xlog_recover_do_inode_trans( ...@@ -2490,9 +2484,8 @@ xlog_recover_do_inode_trans(
write_inode_buffer: write_inode_buffer:
if (ITEM_TYPE(item) == XFS_LI_INODE) { if (ITEM_TYPE(item) == XFS_LI_INODE) {
ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL || ASSERT(bp->b_mount == NULL || bp->b_mount == mp);
XFS_BUF_FSPRIVATE(bp, xfs_mount_t *) == mp); bp->b_mount = mp;
XFS_BUF_SET_FSPRIVATE(bp, mp);
XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
xfs_bdwrite(mp, bp); xfs_bdwrite(mp, bp);
} else { } else {
...@@ -2623,9 +2616,8 @@ xlog_recover_do_dquot_trans( ...@@ -2623,9 +2616,8 @@ xlog_recover_do_dquot_trans(
memcpy(ddq, recddq, item->ri_buf[1].i_len); memcpy(ddq, recddq, item->ri_buf[1].i_len);
ASSERT(dq_f->qlf_size == 2); ASSERT(dq_f->qlf_size == 2);
ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL || ASSERT(bp->b_mount == NULL || bp->b_mount == mp);
XFS_BUF_FSPRIVATE(bp, xfs_mount_t *) == mp); bp->b_mount = mp;
XFS_BUF_SET_FSPRIVATE(bp, mp);
XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone); XFS_BUF_SET_IODONE_FUNC(bp, xlog_recover_iodone);
xfs_bdwrite(mp, bp); xfs_bdwrite(mp, bp);
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#ifndef __XFS_MOUNT_H__ #ifndef __XFS_MOUNT_H__
#define __XFS_MOUNT_H__ #define __XFS_MOUNT_H__
#include "xfs_sync.h"
typedef struct xfs_trans_reservations { typedef struct xfs_trans_reservations {
uint tr_write; /* extent alloc trans */ uint tr_write; /* extent alloc trans */
uint tr_itruncate; /* truncate trans */ uint tr_itruncate; /* truncate trans */
...@@ -53,6 +51,8 @@ typedef struct xfs_trans_reservations { ...@@ -53,6 +51,8 @@ typedef struct xfs_trans_reservations {
#else /* __KERNEL__ */ #else /* __KERNEL__ */
#include "xfs_sync.h"
struct cred; struct cred;
struct log; struct log;
struct xfs_mount_args; struct xfs_mount_args;
......
...@@ -41,31 +41,6 @@ ...@@ -41,31 +41,6 @@
#include "xfs_vnodeops.h" #include "xfs_vnodeops.h"
/*
* Given an array of up to 4 inode pointers, unlock the pointed to inodes.
* If there are fewer than 4 entries in the array, the empty entries will
* be at the end and will have NULL pointers in them.
*/
STATIC void
xfs_rename_unlock4(
xfs_inode_t **i_tab,
uint lock_mode)
{
int i;
xfs_iunlock(i_tab[0], lock_mode);
for (i = 1; i < 4; i++) {
if (i_tab[i] == NULL)
break;
/*
* Watch out for duplicate entries in the table.
*/
if (i_tab[i] != i_tab[i-1])
xfs_iunlock(i_tab[i], lock_mode);
}
}
/* /*
* Enter all inodes for a rename transaction into a sorted array. * Enter all inodes for a rename transaction into a sorted array.
*/ */
...@@ -204,19 +179,6 @@ xfs_rename( ...@@ -204,19 +179,6 @@ xfs_rename(
*/ */
xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL);
/*
* If we are using project inheritance, we only allow renames
* into our tree when the project IDs are the same; else the
* tree quota mechanism would be circumvented.
*/
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
error = XFS_ERROR(EXDEV);
xfs_rename_unlock4(inodes, XFS_ILOCK_EXCL);
xfs_trans_cancel(tp, cancel_flags);
goto std_return;
}
/* /*
* Join all the inodes to the transaction. From this point on, * Join all the inodes to the transaction. From this point on,
* we can rely on either trans_commit or trans_cancel to unlock * we can rely on either trans_commit or trans_cancel to unlock
...@@ -241,6 +203,17 @@ xfs_rename( ...@@ -241,6 +203,17 @@ xfs_rename(
xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL);
} }
/*
* If we are using project inheritance, we only allow renames
* into our tree when the project IDs are the same; else the
* tree quota mechanism would be circumvented.
*/
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
error = XFS_ERROR(EXDEV);
goto error_return;
}
/* /*
* Set up the target. * Set up the target.
*/ */
......
...@@ -406,7 +406,7 @@ xfs_bwrite( ...@@ -406,7 +406,7 @@ xfs_bwrite(
* XXXsup how does this work for quotas. * XXXsup how does this work for quotas.
*/ */
XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb); XFS_BUF_SET_BDSTRAT_FUNC(bp, xfs_bdstrat_cb);
XFS_BUF_SET_FSPRIVATE3(bp, mp); bp->b_mount = mp;
XFS_BUF_WRITE(bp); XFS_BUF_WRITE(bp);
if ((error = XFS_bwrite(bp))) { if ((error = XFS_bwrite(bp))) {
......
...@@ -79,6 +79,7 @@ struct xfs_mount; ...@@ -79,6 +79,7 @@ struct xfs_mount;
#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
#define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
#define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */
#define XFS_SB_VERSION2_OKREALFBITS \ #define XFS_SB_VERSION2_OKREALFBITS \
(XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
......
...@@ -70,7 +70,6 @@ xfs_setattr( ...@@ -70,7 +70,6 @@ xfs_setattr(
gid_t gid=0, igid=0; gid_t gid=0, igid=0;
int timeflags = 0; int timeflags = 0;
struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
int file_owner;
int need_iolock = 1; int need_iolock = 1;
xfs_itrace_entry(ip); xfs_itrace_entry(ip);
...@@ -81,6 +80,10 @@ xfs_setattr( ...@@ -81,6 +80,10 @@ xfs_setattr(
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
code = -inode_change_ok(inode, iattr);
if (code)
return code;
olddquot1 = olddquot2 = NULL; olddquot1 = olddquot2 = NULL;
udqp = gdqp = NULL; udqp = gdqp = NULL;
...@@ -158,56 +161,6 @@ xfs_setattr( ...@@ -158,56 +161,6 @@ xfs_setattr(
xfs_ilock(ip, lock_flags); xfs_ilock(ip, lock_flags);
/* boolean: are we the file owner? */
file_owner = (current_fsuid() == ip->i_d.di_uid);
/*
* Change various properties of a file.
* Only the owner or users with CAP_FOWNER
* capability may do these things.
*/
if (mask & (ATTR_MODE|ATTR_UID|ATTR_GID)) {
/*
* CAP_FOWNER overrides the following restrictions:
*
* The user ID of the calling process must be equal
* to the file owner ID, except in cases where the
* CAP_FSETID capability is applicable.
*/
if (!file_owner && !capable(CAP_FOWNER)) {
code = XFS_ERROR(EPERM);
goto error_return;
}
/*
* CAP_FSETID overrides the following restrictions:
*
* The effective user ID of the calling process shall match
* the file owner when setting the set-user-ID and
* set-group-ID bits on that file.
*
* The effective group ID or one of the supplementary group
* IDs of the calling process shall match the group owner of
* the file when setting the set-group-ID bit on that file
*/
if (mask & ATTR_MODE) {
mode_t m = 0;
if ((iattr->ia_mode & S_ISUID) && !file_owner)
m |= S_ISUID;
if ((iattr->ia_mode & S_ISGID) &&
!in_group_p((gid_t)ip->i_d.di_gid))
m |= S_ISGID;
#if 0
/* Linux allows this, Irix doesn't. */
if ((iattr->ia_mode & S_ISVTX) && !S_ISDIR(ip->i_d.di_mode))
m |= S_ISVTX;
#endif
if (m && !capable(CAP_FSETID))
iattr->ia_mode &= ~m;
}
}
/* /*
* Change file ownership. Must be the owner or privileged. * Change file ownership. Must be the owner or privileged.
*/ */
...@@ -223,22 +176,6 @@ xfs_setattr( ...@@ -223,22 +176,6 @@ xfs_setattr(
gid = (mask & ATTR_GID) ? iattr->ia_gid : igid; gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid; uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
/*
* CAP_CHOWN overrides the following restrictions:
*
* If _POSIX_CHOWN_RESTRICTED is defined, this capability
* shall override the restriction that a process cannot
* change the user ID of a file it owns and the restriction
* that the group ID supplied to the chown() function
* shall be equal to either the group ID or one of the
* supplementary group IDs of the calling process.
*/
if ((iuid != uid ||
(igid != gid && !in_group_p((gid_t)gid))) &&
!capable(CAP_CHOWN)) {
code = XFS_ERROR(EPERM);
goto error_return;
}
/* /*
* Do a quota reservation only if uid/gid is actually * Do a quota reservation only if uid/gid is actually
* going to change. * going to change.
...@@ -276,36 +213,22 @@ xfs_setattr( ...@@ -276,36 +213,22 @@ xfs_setattr(
code = XFS_ERROR(EINVAL); code = XFS_ERROR(EINVAL);
goto error_return; goto error_return;
} }
/* /*
* Make sure that the dquots are attached to the inode. * Make sure that the dquots are attached to the inode.
*/ */
if ((code = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED))) code = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED);
if (code)
goto error_return; goto error_return;
}
/* /*
* Change file access or modified times. * Now we can make the changes. Before we join the inode
*/ * to the transaction, if ATTR_SIZE is set then take care of
if (mask & (ATTR_ATIME|ATTR_MTIME)) { * the part of the truncation that must be done without the
if (!file_owner) { * inode lock. This needs to be done before joining the inode
if ((mask & (ATTR_MTIME_SET|ATTR_ATIME_SET)) && * to the transaction, because the inode cannot be unlocked
!capable(CAP_FOWNER)) { * once it is a part of the transaction.
code = XFS_ERROR(EPERM); */
goto error_return;
}
}
}
/*
* Now we can make the changes. Before we join the inode
* to the transaction, if ATTR_SIZE is set then take care of
* the part of the truncation that must be done without the
* inode lock. This needs to be done before joining the inode
* to the transaction, because the inode cannot be unlocked
* once it is a part of the transaction.
*/
if (mask & ATTR_SIZE) {
code = 0;
if (iattr->ia_size > ip->i_size) { if (iattr->ia_size > ip->i_size) {
/* /*
* Do the first part of growing a file: zero any data * Do the first part of growing a file: zero any data
...@@ -360,17 +283,10 @@ xfs_setattr( ...@@ -360,17 +283,10 @@ xfs_setattr(
} }
commit_flags = XFS_TRANS_RELEASE_LOG_RES; commit_flags = XFS_TRANS_RELEASE_LOG_RES;
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
}
if (tp) {
xfs_trans_ijoin(tp, ip, lock_flags); xfs_trans_ijoin(tp, ip, lock_flags);
xfs_trans_ihold(tp, ip); xfs_trans_ihold(tp, ip);
}
/*
* Truncate file. Must have write permission and not be a directory.
*/
if (mask & ATTR_SIZE) {
/* /*
* Only change the c/mtime if we are changing the size * Only change the c/mtime if we are changing the size
* or we are explicitly asked to change it. This handles * or we are explicitly asked to change it. This handles
...@@ -410,20 +326,9 @@ xfs_setattr( ...@@ -410,20 +326,9 @@ xfs_setattr(
*/ */
xfs_iflags_set(ip, XFS_ITRUNCATED); xfs_iflags_set(ip, XFS_ITRUNCATED);
} }
} } else if (tp) {
xfs_trans_ijoin(tp, ip, lock_flags);
/* xfs_trans_ihold(tp, ip);
* Change file access modes.
*/
if (mask & ATTR_MODE) {
ip->i_d.di_mode &= S_IFMT;
ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT;
inode->i_mode &= S_IFMT;
inode->i_mode |= iattr->ia_mode & ~S_IFMT;
xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE);
timeflags |= XFS_ICHGTIME_CHG;
} }
/* /*
...@@ -471,6 +376,24 @@ xfs_setattr( ...@@ -471,6 +376,24 @@ xfs_setattr(
timeflags |= XFS_ICHGTIME_CHG; timeflags |= XFS_ICHGTIME_CHG;
} }
/*
* Change file access modes.
*/
if (mask & ATTR_MODE) {
umode_t mode = iattr->ia_mode;
if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
mode &= ~S_ISGID;
ip->i_d.di_mode &= S_IFMT;
ip->i_d.di_mode |= mode & ~S_IFMT;
inode->i_mode &= S_IFMT;
inode->i_mode |= mode & ~S_IFMT;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
timeflags |= XFS_ICHGTIME_CHG;
}
/* /*
* Change file access or modified times. * Change file access or modified times.
......
...@@ -53,8 +53,6 @@ int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value, ...@@ -53,8 +53,6 @@ int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
int xfs_attr_remove(struct xfs_inode *dp, const char *name, int flags); int xfs_attr_remove(struct xfs_inode *dp, const char *name, int flags);
int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize, int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
int flags, struct attrlist_cursor_kern *cursor); int flags, struct attrlist_cursor_kern *cursor);
int xfs_ioctl(struct xfs_inode *ip, struct file *filp,
int ioflags, unsigned int cmd, void __user *arg);
ssize_t xfs_read(struct xfs_inode *ip, struct kiocb *iocb, ssize_t xfs_read(struct xfs_inode *ip, struct kiocb *iocb,
const struct iovec *iovp, unsigned int segs, const struct iovec *iovp, unsigned int segs,
loff_t *offset, int ioflags); loff_t *offset, int ioflags);
......
...@@ -81,6 +81,14 @@ extern int dir_notify_enable; ...@@ -81,6 +81,14 @@ extern int dir_notify_enable;
#define FMODE_WRITE_IOCTL ((__force fmode_t)128) #define FMODE_WRITE_IOCTL ((__force fmode_t)128)
#define FMODE_NDELAY_NOW ((__force fmode_t)256) #define FMODE_NDELAY_NOW ((__force fmode_t)256)
/*
* Don't update ctime and mtime.
*
* Currently a special hack for the XFS open_by_handle ioctl, but we'll
* hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon.
*/
#define FMODE_NOCMTIME ((__force fmode_t)2048)
#define RW_MASK 1 #define RW_MASK 1
#define RWA_MASK 2 #define RWA_MASK 2
#define READ 0 #define READ 0
......
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