2008-10-30 00:06:18 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000-2006 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
|
|
|
|
*/
|
2008-10-30 00:06:08 -06:00
|
|
|
#ifndef XFS_SYNC_H
|
|
|
|
#define XFS_SYNC_H 1
|
|
|
|
|
2008-10-30 00:06:18 -06:00
|
|
|
struct xfs_mount;
|
2009-02-09 00:47:34 -07:00
|
|
|
struct xfs_perag;
|
2008-10-30 00:06:18 -06:00
|
|
|
|
2013-08-15 12:08:02 -06:00
|
|
|
struct xfs_eofblocks {
|
|
|
|
__u32 eof_flags;
|
|
|
|
kuid_t eof_uid;
|
|
|
|
kgid_t eof_gid;
|
|
|
|
prid_t eof_prid;
|
|
|
|
__u64 eof_min_file_size;
|
|
|
|
};
|
|
|
|
|
2009-06-08 07:37:16 -06:00
|
|
|
#define SYNC_WAIT 0x0001 /* wait for i/o to complete */
|
|
|
|
#define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */
|
2008-10-30 00:06:18 -06:00
|
|
|
|
2014-11-27 20:25:04 -07:00
|
|
|
/*
|
|
|
|
* tags for inode radix tree
|
|
|
|
*/
|
|
|
|
#define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup
|
|
|
|
in xfs_inode_ag_iterator */
|
|
|
|
#define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */
|
|
|
|
#define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */
|
2016-10-03 10:11:46 -06:00
|
|
|
#define XFS_ICI_COWBLOCKS_TAG 2 /* inode can have cow blocks to gc */
|
2014-11-27 20:25:04 -07:00
|
|
|
|
2013-08-12 04:49:34 -06:00
|
|
|
/*
|
|
|
|
* Flags for xfs_iget()
|
|
|
|
*/
|
|
|
|
#define XFS_IGET_CREATE 0x1
|
|
|
|
#define XFS_IGET_UNTRUSTED 0x2
|
|
|
|
#define XFS_IGET_DONTCACHE 0x4
|
|
|
|
|
2012-10-08 04:56:11 -06:00
|
|
|
int xfs_iget(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino,
|
|
|
|
uint flags, uint lock_flags, xfs_inode_t **ipp);
|
|
|
|
|
xfs: recovery of swap extents operations for CRC filesystems
This is the recovery side of the btree block owner change operation
performed by swapext on CRC enabled filesystems. We detect that an
owner change is needed by the flag that has been placed on the inode
log format flag field. Because the inode recovery is being replayed
after the buffers that make up the BMBT in the given checkpoint, we
can walk all the buffers and directly modify them when we see the
flag set on an inode.
Because the inode can be relogged and hence present in multiple
chekpoints with the "change owner" flag set, we could do multiple
passes across the inode to do this change. While this isn't optimal,
we can't directly ignore the flag as there may be multiple
independent swap extent operations being replayed on the same inode
in different checkpoints so we can't ignore them.
Further, because the owner change operation uses ordered buffers, we
might have buffers that are newer on disk than the current
checkpoint and so already have the owner changed in them. Hence we
cannot just peek at a buffer in the tree and check that it has the
correct owner and assume that the change was completed.
So, for the moment just brute force the owner change every time we
see an inode with the flag set. Note that we have to be careful here
because the owner of the buffers may point to either the old owner
or the new owner. Currently the verifier can't verify the owner
directly, so there is no failure case here right now. If we verify
the owner exactly in future, then we'll have to take this into
account.
This was tested in terms of normal operation via xfstests - all of
the fsr tests now pass without failure. however, we really need to
modify xfs/227 to stress v3 inodes correctly to ensure we fully
cover this case for v5 filesystems.
In terms of recovery testing, I used a hacked version of xfs_fsr
that held the temp inode open for a few seconds before exiting so
that the filesystem could be shut down with an open owner change
recovery flags set on at least the temp inode. fsr leaves the temp
inode unlinked and in btree format, so this was necessary for the
owner change to be reliably replayed.
logprint confirmed the tmp inode in the log had the correct flag set:
INO: cnt:3 total:3 a:0x69e9e0 len:56 a:0x69ea20 len:176 a:0x69eae0 len:88
INODE: #regs:3 ino:0x44 flags:0x209 dsize:88
^^^^^
0x200 is set, indicating a data fork owner change needed to be
replayed on inode 0x44. A printk in the revoery code confirmed that
the inode change was recovered:
XFS (vdc): Mounting Filesystem
XFS (vdc): Starting recovery (logdev: internal)
recovering owner change ino 0x44
XFS (vdc): Version 5 superblock detected. This kernel L support enabled!
Use of these features in this kernel is at your own risk!
XFS (vdc): Ending recovery (logdev: internal)
The script used to test this was:
$ cat ./recovery-fsr.sh
#!/bin/bash
dev=/dev/vdc
mntpt=/mnt/scratch
testfile=$mntpt/testfile
umount $mntpt
mkfs.xfs -f -m crc=1 $dev
mount $dev $mntpt
chmod 777 $mntpt
for i in `seq 10000 -1 0`; do
xfs_io -f -d -c "pwrite $(($i * 4096)) 4096" $testfile > /dev/null 2>&1
done
xfs_bmap -vp $testfile |head -20
xfs_fsr -d -v $testfile &
sleep 10
/home/dave/src/xfstests-dev/src/godown -f $mntpt
wait
umount $mntpt
xfs_logprint -t $dev |tail -20
time mount $dev $mntpt
xfs_bmap -vp $testfile
umount $mntpt
$
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
2013-08-29 18:23:45 -06:00
|
|
|
/* recovery needs direct inode allocation capability */
|
|
|
|
struct xfs_inode * xfs_inode_alloc(struct xfs_mount *mp, xfs_ino_t ino);
|
|
|
|
void xfs_inode_free(struct xfs_inode *ip);
|
|
|
|
|
2012-10-08 04:55:59 -06:00
|
|
|
void xfs_reclaim_worker(struct work_struct *work);
|
2008-10-30 00:06:18 -06:00
|
|
|
|
2009-06-08 07:35:12 -06:00
|
|
|
int xfs_reclaim_inodes(struct xfs_mount *mp, int mode);
|
2011-07-07 22:14:46 -06:00
|
|
|
int xfs_reclaim_inodes_count(struct xfs_mount *mp);
|
2013-08-27 18:17:57 -06:00
|
|
|
long xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan);
|
2008-10-30 00:37:03 -06:00
|
|
|
|
2008-10-30 00:37:26 -06:00
|
|
|
void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
|
2009-06-08 07:35:27 -06:00
|
|
|
|
2012-11-06 07:50:38 -07:00
|
|
|
void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
|
|
|
|
void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
|
2012-11-07 10:21:12 -07:00
|
|
|
int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *);
|
2014-07-24 03:49:28 -06:00
|
|
|
int xfs_inode_free_quota_eofblocks(struct xfs_inode *ip);
|
2012-11-06 07:50:47 -07:00
|
|
|
void xfs_eofblocks_worker(struct work_struct *);
|
2016-06-20 19:53:28 -06:00
|
|
|
void xfs_queue_eofblocks(struct xfs_mount *);
|
2012-11-06 07:50:38 -07:00
|
|
|
|
2016-10-03 10:11:46 -06:00
|
|
|
void xfs_inode_set_cowblocks_tag(struct xfs_inode *ip);
|
|
|
|
void xfs_inode_clear_cowblocks_tag(struct xfs_inode *ip);
|
|
|
|
int xfs_icache_free_cowblocks(struct xfs_mount *, struct xfs_eofblocks *);
|
|
|
|
int xfs_inode_free_quota_cowblocks(struct xfs_inode *ip);
|
|
|
|
void xfs_cowblocks_worker(struct work_struct *);
|
|
|
|
|
2009-06-08 07:35:27 -06:00
|
|
|
int xfs_inode_ag_iterator(struct xfs_mount *mp,
|
2014-04-14 03:04:19 -06:00
|
|
|
int (*execute)(struct xfs_inode *ip, int flags, void *args),
|
2012-11-06 07:50:39 -07:00
|
|
|
int flags, void *args);
|
|
|
|
int xfs_inode_ag_iterator_tag(struct xfs_mount *mp,
|
2014-04-14 03:04:19 -06:00
|
|
|
int (*execute)(struct xfs_inode *ip, int flags, void *args),
|
2012-11-06 07:50:39 -07:00
|
|
|
int flags, void *args, int tag);
|
2010-04-28 17:55:50 -06:00
|
|
|
|
2013-08-15 12:08:02 -06:00
|
|
|
static inline int
|
|
|
|
xfs_fs_eofblocks_from_user(
|
|
|
|
struct xfs_fs_eofblocks *src,
|
|
|
|
struct xfs_eofblocks *dst)
|
|
|
|
{
|
|
|
|
if (src->eof_version != XFS_EOFBLOCKS_VERSION)
|
2014-06-24 22:58:08 -06:00
|
|
|
return -EINVAL;
|
2013-08-15 12:08:02 -06:00
|
|
|
|
|
|
|
if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
|
2014-06-24 22:58:08 -06:00
|
|
|
return -EINVAL;
|
2013-08-15 12:08:02 -06:00
|
|
|
|
|
|
|
if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
|
|
|
|
memchr_inv(src->pad64, 0, sizeof(src->pad64)))
|
2014-06-24 22:58:08 -06:00
|
|
|
return -EINVAL;
|
2013-08-15 12:08:02 -06:00
|
|
|
|
|
|
|
dst->eof_flags = src->eof_flags;
|
|
|
|
dst->eof_prid = src->eof_prid;
|
|
|
|
dst->eof_min_file_size = src->eof_min_file_size;
|
|
|
|
|
|
|
|
dst->eof_uid = INVALID_UID;
|
|
|
|
if (src->eof_flags & XFS_EOF_FLAGS_UID) {
|
|
|
|
dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
|
|
|
|
if (!uid_valid(dst->eof_uid))
|
2014-06-24 22:58:08 -06:00
|
|
|
return -EINVAL;
|
2013-08-15 12:08:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
dst->eof_gid = INVALID_GID;
|
|
|
|
if (src->eof_flags & XFS_EOF_FLAGS_GID) {
|
|
|
|
dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
|
|
|
|
if (!gid_valid(dst->eof_gid))
|
2014-06-24 22:58:08 -06:00
|
|
|
return -EINVAL;
|
2013-08-15 12:08:02 -06:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-30 00:06:08 -06:00
|
|
|
#endif
|