Commit 60bb8154 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-6.1-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs updates from Dave Chinner:
 "There are relatively few updates this cycle; half the cycle was eaten
  by a grue, the other half was eaten by a tricky data corruption issue
  that I still haven't entirely solved.

  Hence there's no major changes in this cycle and it's largely just
  minor cleanups and small bug fixes:

   - fixes for filesystem shutdown procedure during a DAX memory failure
     notification

   - bug fixes

   - logic cleanups

   - log message cleanups

   - updates to use vfs{g,u}id_t helpers where appropriate"

* tag 'xfs-6.1-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: on memory failure, only shut down fs after scanning all mappings
  xfs: rearrange the logic and remove the broken comment for xfs_dir2_isxx
  xfs: trim the mapp array accordingly in xfs_da_grow_inode_int
  xfs: do not need to check return value of xlog_kvmalloc()
  xfs: port to vfs{g,u}id_t and associated helpers
  xfs: remove xfs_setattr_time() declaration
  xfs: Remove the unneeded result variable
  xfs: missing space in xfs trace log
  xfs: simplify if-else condition in xfs_reflink_trim_around_shared
  xfs: simplify if-else condition in xfs_validate_new_dalign
  xfs: replace unnecessary seq_printf with seq_puts
  xfs: clean up "%Ld/%Lu" which doesn't meet C standard
  xfs: remove redundant else for clean code
  xfs: remove the redundant word in comment
parents 5d170fe4 e033f40b
...@@ -294,7 +294,7 @@ xfs_check_block( ...@@ -294,7 +294,7 @@ xfs_check_block(
else else
thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr); thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr);
if (*thispa == *pp) { if (*thispa == *pp) {
xfs_warn(mp, "%s: thispa(%d) == pp(%d) %Ld", xfs_warn(mp, "%s: thispa(%d) == pp(%d) %lld",
__func__, j, i, __func__, j, i,
(unsigned long long)be64_to_cpu(*thispa)); (unsigned long long)be64_to_cpu(*thispa));
xfs_err(mp, "%s: ptrs are equal in node\n", xfs_err(mp, "%s: ptrs are equal in node\n",
......
...@@ -2192,8 +2192,8 @@ xfs_da_grow_inode_int( ...@@ -2192,8 +2192,8 @@ xfs_da_grow_inode_int(
*/ */
mapp = kmem_alloc(sizeof(*mapp) * count, 0); mapp = kmem_alloc(sizeof(*mapp) * count, 0);
for (b = *bno, mapi = 0; b < *bno + count; ) { for (b = *bno, mapi = 0; b < *bno + count; ) {
nmap = min(XFS_BMAP_MAX_NMAP, count);
c = (int)(*bno + count - b); c = (int)(*bno + count - b);
nmap = min(XFS_BMAP_MAX_NMAP, c);
error = xfs_bmapi_write(tp, dp, b, c, error = xfs_bmapi_write(tp, dp, b, c,
xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
args->total, &mapp[mapi], &nmap); args->total, &mapp[mapi], &nmap);
......
...@@ -261,7 +261,7 @@ xfs_dir_createname( ...@@ -261,7 +261,7 @@ xfs_dir_createname(
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
int v; /* type-checking value */ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
...@@ -357,7 +357,7 @@ xfs_dir_lookup( ...@@ -357,7 +357,7 @@ xfs_dir_lookup(
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
int v; /* type-checking value */ bool v;
int lock_mode; int lock_mode;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
...@@ -435,7 +435,7 @@ xfs_dir_removename( ...@@ -435,7 +435,7 @@ xfs_dir_removename(
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
int v; /* type-checking value */ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove); XFS_STATS_INC(dp->i_mount, xs_dir_remove);
...@@ -493,7 +493,7 @@ xfs_dir_replace( ...@@ -493,7 +493,7 @@ xfs_dir_replace(
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
int v; /* type-checking value */ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
...@@ -610,19 +610,23 @@ xfs_dir2_grow_inode( ...@@ -610,19 +610,23 @@ xfs_dir2_grow_inode(
int int
xfs_dir2_isblock( xfs_dir2_isblock(
struct xfs_da_args *args, struct xfs_da_args *args,
int *vp) /* out: 1 is block, 0 is not block */ bool *isblock)
{ {
xfs_fileoff_t last; /* last file offset */ struct xfs_mount *mp = args->dp->i_mount;
int rval; xfs_fileoff_t eof;
int error;
if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK))) error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
return rval; if (error)
rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize; return error;
if (XFS_IS_CORRUPT(args->dp->i_mount,
rval != 0 && *isblock = false;
args->dp->i_disk_size != args->geo->blksize)) if (XFS_FSB_TO_B(mp, eof) != args->geo->blksize)
return 0;
*isblock = true;
if (XFS_IS_CORRUPT(mp, args->dp->i_disk_size != args->geo->blksize))
return -EFSCORRUPTED; return -EFSCORRUPTED;
*vp = rval;
return 0; return 0;
} }
...@@ -632,14 +636,20 @@ xfs_dir2_isblock( ...@@ -632,14 +636,20 @@ xfs_dir2_isblock(
int int
xfs_dir2_isleaf( xfs_dir2_isleaf(
struct xfs_da_args *args, struct xfs_da_args *args,
int *vp) /* out: 1 is block, 0 is not block */ bool *isleaf)
{ {
xfs_fileoff_t last; /* last file offset */ xfs_fileoff_t eof;
int rval; int error;
if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK))) error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
return rval; if (error)
*vp = last == args->geo->leafblk + args->geo->fsbcount; return error;
*isleaf = false;
if (eof != args->geo->leafblk + args->geo->fsbcount)
return 0;
*isleaf = true;
return 0; return 0;
} }
......
...@@ -61,8 +61,8 @@ extern int xfs_dir2_sf_to_block(struct xfs_da_args *args); ...@@ -61,8 +61,8 @@ extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
/* /*
* Interface routines used by userspace utilities * Interface routines used by userspace utilities
*/ */
extern int xfs_dir2_isblock(struct xfs_da_args *args, int *r); extern int xfs_dir2_isblock(struct xfs_da_args *args, bool *isblock);
extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r); extern int xfs_dir2_isleaf(struct xfs_da_args *args, bool *isleaf);
extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
struct xfs_buf *bp); struct xfs_buf *bp);
......
...@@ -865,7 +865,6 @@ xfs_dir2_sf_lookup( ...@@ -865,7 +865,6 @@ xfs_dir2_sf_lookup(
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
int i; /* entry index */ int i; /* entry index */
int error;
xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
enum xfs_dacmp cmp; /* comparison result */ enum xfs_dacmp cmp; /* comparison result */
...@@ -929,8 +928,7 @@ xfs_dir2_sf_lookup( ...@@ -929,8 +928,7 @@ xfs_dir2_sf_lookup(
if (!ci_sfep) if (!ci_sfep)
return -ENOENT; return -ENOENT;
/* otherwise process the CI match as required by the caller */ /* otherwise process the CI match as required by the caller */
error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen); return xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen);
return error;
} }
/* /*
......
...@@ -78,7 +78,7 @@ xfs_iformat_local( ...@@ -78,7 +78,7 @@ xfs_iformat_local(
*/ */
if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) {
xfs_warn(ip->i_mount, xfs_warn(ip->i_mount,
"corrupt inode %Lu (bad size %d for local fork, size = %zd).", "corrupt inode %llu (bad size %d for local fork, size = %zd).",
(unsigned long long) ip->i_ino, size, (unsigned long long) ip->i_ino, size,
XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); XFS_DFORK_SIZE(dip, ip->i_mount, whichfork));
xfs_inode_verifier_error(ip, -EFSCORRUPTED, xfs_inode_verifier_error(ip, -EFSCORRUPTED,
...@@ -192,7 +192,7 @@ xfs_iformat_btree( ...@@ -192,7 +192,7 @@ xfs_iformat_btree(
XFS_DFORK_SIZE(dip, mp, whichfork) || XFS_DFORK_SIZE(dip, mp, whichfork) ||
ifp->if_nextents > ip->i_nblocks) || ifp->if_nextents > ip->i_nblocks) ||
level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) { level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) {
xfs_warn(mp, "corrupt inode %Lu (btree).", xfs_warn(mp, "corrupt inode %llu (btree).",
(unsigned long long) ip->i_ino); (unsigned long long) ip->i_ino);
xfs_inode_verifier_error(ip, -EFSCORRUPTED, xfs_inode_verifier_error(ip, -EFSCORRUPTED,
"xfs_iformat_btree", dfp, size, "xfs_iformat_btree", dfp, size,
......
...@@ -676,7 +676,7 @@ xchk_directory_blocks( ...@@ -676,7 +676,7 @@ xchk_directory_blocks(
xfs_dablk_t dabno; xfs_dablk_t dabno;
xfs_dir2_db_t last_data_db = 0; xfs_dir2_db_t last_data_db = 0;
bool found; bool found;
int is_block = 0; bool is_block = false;
int error; int error;
/* Ignore local format directories. */ /* Ignore local format directories. */
......
...@@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc( ...@@ -86,8 +86,6 @@ xfs_attri_log_nameval_alloc(
*/ */
nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) + nv = xlog_kvmalloc(sizeof(struct xfs_attri_log_nameval) +
name_len + value_len); name_len + value_len);
if (!nv)
return nv;
nv->name.i_addr = nv + 1; nv->name.i_addr = nv + 1;
nv->name.i_len = name_len; nv->name.i_len = name_len;
...@@ -441,8 +439,6 @@ xfs_attr_create_intent( ...@@ -441,8 +439,6 @@ xfs_attr_create_intent(
attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name, attr->xattri_nameval = xfs_attri_log_nameval_alloc(args->name,
args->namelen, args->value, args->valuelen); args->namelen, args->value, args->valuelen);
} }
if (!attr->xattri_nameval)
return ERR_PTR(-ENOMEM);
attrip = xfs_attri_init(mp, attr->xattri_nameval); attrip = xfs_attri_init(mp, attr->xattri_nameval);
xfs_trans_add_item(tp, &attrip->attri_item); xfs_trans_add_item(tp, &attrip->attri_item);
...@@ -762,8 +758,6 @@ xlog_recover_attri_commit_pass2( ...@@ -762,8 +758,6 @@ xlog_recover_attri_commit_pass2(
nv = xfs_attri_log_nameval_alloc(attr_name, nv = xfs_attri_log_nameval_alloc(attr_name,
attri_formatp->alfi_name_len, attr_value, attri_formatp->alfi_name_len, attr_value,
attri_formatp->alfi_value_len); attri_formatp->alfi_value_len);
if (!nv)
return -ENOMEM;
attrip = xfs_attri_init(mp, nv); attrip = xfs_attri_init(mp, nv);
error = xfs_attri_copy_format(&item->ri_buf[0], &attrip->attri_format); error = xfs_attri_copy_format(&item->ri_buf[0], &attrip->attri_format);
......
...@@ -512,7 +512,7 @@ xfs_readdir( ...@@ -512,7 +512,7 @@ xfs_readdir(
{ {
struct xfs_da_args args = { NULL }; struct xfs_da_args args = { NULL };
unsigned int lock_mode; unsigned int lock_mode;
int isblock; bool isblock;
int error; int error;
trace_xfs_readdir(dp); trace_xfs_readdir(dp);
......
...@@ -835,9 +835,8 @@ xfs_init_new_inode( ...@@ -835,9 +835,8 @@ xfs_init_new_inode(
* ID or one of the supplementary group IDs, the S_ISGID bit is cleared * ID or one of the supplementary group IDs, the S_ISGID bit is cleared
* (and only if the irix_sgid_inherit compatibility variable is set). * (and only if the irix_sgid_inherit compatibility variable is set).
*/ */
if (irix_sgid_inherit && if (irix_sgid_inherit && (inode->i_mode & S_ISGID) &&
(inode->i_mode & S_ISGID) && !vfsgid_in_group_p(i_gid_into_vfsgid(mnt_userns, inode)))
!in_group_p(i_gid_into_mnt(mnt_userns, inode)))
inode->i_mode &= ~S_ISGID; inode->i_mode &= ~S_ISGID;
ip->i_disk_size = 0; ip->i_disk_size = 0;
...@@ -3119,7 +3118,7 @@ xfs_iflush( ...@@ -3119,7 +3118,7 @@ xfs_iflush(
if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC), if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
mp, XFS_ERRTAG_IFLUSH_1)) { mp, XFS_ERRTAG_IFLUSH_1)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH, xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad inode %Lu magic number 0x%x, ptr "PTR_FMT, "%s: Bad inode %llu magic number 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip);
goto flush_out; goto flush_out;
} }
...@@ -3129,7 +3128,7 @@ xfs_iflush( ...@@ -3129,7 +3128,7 @@ xfs_iflush(
ip->i_df.if_format != XFS_DINODE_FMT_BTREE, ip->i_df.if_format != XFS_DINODE_FMT_BTREE,
mp, XFS_ERRTAG_IFLUSH_3)) { mp, XFS_ERRTAG_IFLUSH_3)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH, xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad regular inode %Lu, ptr "PTR_FMT, "%s: Bad regular inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip); __func__, ip->i_ino, ip);
goto flush_out; goto flush_out;
} }
...@@ -3140,7 +3139,7 @@ xfs_iflush( ...@@ -3140,7 +3139,7 @@ xfs_iflush(
ip->i_df.if_format != XFS_DINODE_FMT_LOCAL, ip->i_df.if_format != XFS_DINODE_FMT_LOCAL,
mp, XFS_ERRTAG_IFLUSH_4)) { mp, XFS_ERRTAG_IFLUSH_4)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH, xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad directory inode %Lu, ptr "PTR_FMT, "%s: Bad directory inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip); __func__, ip->i_ino, ip);
goto flush_out; goto flush_out;
} }
...@@ -3158,7 +3157,7 @@ xfs_iflush( ...@@ -3158,7 +3157,7 @@ xfs_iflush(
if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize, if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
mp, XFS_ERRTAG_IFLUSH_6)) { mp, XFS_ERRTAG_IFLUSH_6)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH, xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: bad inode %Lu, forkoff 0x%x, ptr "PTR_FMT, "%s: bad inode %llu, forkoff 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, ip->i_forkoff, ip); __func__, ip->i_ino, ip->i_forkoff, ip);
goto flush_out; goto flush_out;
} }
......
...@@ -550,7 +550,7 @@ xfs_inode_item_push( ...@@ -550,7 +550,7 @@ xfs_inode_item_push(
if (!bp || (ip->i_flags & XFS_ISTALE)) { if (!bp || (ip->i_flags & XFS_ISTALE)) {
/* /*
* Inode item/buffer is being being aborted due to cluster * Inode item/buffer is being aborted due to cluster
* buffer deletion. Trigger a log force to have that operation * buffer deletion. Trigger a log force to have that operation
* completed and items removed from the AIL before the next push * completed and items removed from the AIL before the next push
* attempt. * attempt.
......
...@@ -321,7 +321,7 @@ xlog_recover_inode_commit_pass2( ...@@ -321,7 +321,7 @@ xlog_recover_inode_commit_pass2(
*/ */
if (XFS_IS_CORRUPT(mp, !xfs_verify_magic16(bp, dip->di_magic))) { if (XFS_IS_CORRUPT(mp, !xfs_verify_magic16(bp, dip->di_magic))) {
xfs_alert(mp, xfs_alert(mp,
"%s: Bad inode magic number, dip = "PTR_FMT", dino bp = "PTR_FMT", ino = %Ld", "%s: Bad inode magic number, dip = "PTR_FMT", dino bp = "PTR_FMT", ino = %lld",
__func__, dip, bp, in_f->ilf_ino); __func__, dip, bp, in_f->ilf_ino);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_release; goto out_release;
...@@ -329,7 +329,7 @@ xlog_recover_inode_commit_pass2( ...@@ -329,7 +329,7 @@ xlog_recover_inode_commit_pass2(
ldip = item->ri_buf[1].i_addr; ldip = item->ri_buf[1].i_addr;
if (XFS_IS_CORRUPT(mp, ldip->di_magic != XFS_DINODE_MAGIC)) { if (XFS_IS_CORRUPT(mp, ldip->di_magic != XFS_DINODE_MAGIC)) {
xfs_alert(mp, xfs_alert(mp,
"%s: Bad inode log record, rec ptr "PTR_FMT", ino %Ld", "%s: Bad inode log record, rec ptr "PTR_FMT", ino %lld",
__func__, item, in_f->ilf_ino); __func__, item, in_f->ilf_ino);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_release; goto out_release;
......
...@@ -558,6 +558,8 @@ xfs_vn_getattr( ...@@ -558,6 +558,8 @@ xfs_vn_getattr(
struct inode *inode = d_inode(path->dentry); struct inode *inode = d_inode(path->dentry);
struct xfs_inode *ip = XFS_I(inode); struct xfs_inode *ip = XFS_I(inode);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
vfsuid_t vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
vfsgid_t vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
trace_xfs_getattr(ip); trace_xfs_getattr(ip);
...@@ -568,8 +570,8 @@ xfs_vn_getattr( ...@@ -568,8 +570,8 @@ xfs_vn_getattr(
stat->dev = inode->i_sb->s_dev; stat->dev = inode->i_sb->s_dev;
stat->mode = inode->i_mode; stat->mode = inode->i_mode;
stat->nlink = inode->i_nlink; stat->nlink = inode->i_nlink;
stat->uid = i_uid_into_mnt(mnt_userns, inode); stat->uid = vfsuid_into_kuid(vfsuid);
stat->gid = i_gid_into_mnt(mnt_userns, inode); stat->gid = vfsgid_into_kgid(vfsgid);
stat->ino = ip->i_ino; stat->ino = ip->i_ino;
stat->atime = inode->i_atime; stat->atime = inode->i_atime;
stat->mtime = inode->i_mtime; stat->mtime = inode->i_mtime;
......
...@@ -13,7 +13,6 @@ extern const struct file_operations xfs_dir_file_operations; ...@@ -13,7 +13,6 @@ extern const struct file_operations xfs_dir_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);
extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
int xfs_vn_setattr_size(struct user_namespace *mnt_userns, int xfs_vn_setattr_size(struct user_namespace *mnt_userns,
struct dentry *dentry, struct iattr *vap); struct dentry *dentry, struct iattr *vap);
......
...@@ -66,6 +66,8 @@ xfs_bulkstat_one_int( ...@@ -66,6 +66,8 @@ xfs_bulkstat_one_int(
struct xfs_bulkstat *buf = bc->buf; struct xfs_bulkstat *buf = bc->buf;
xfs_extnum_t nextents; xfs_extnum_t nextents;
int error = -EINVAL; int error = -EINVAL;
vfsuid_t vfsuid;
vfsgid_t vfsgid;
if (xfs_internal_inum(mp, ino)) if (xfs_internal_inum(mp, ino))
goto out_advance; goto out_advance;
...@@ -81,14 +83,16 @@ xfs_bulkstat_one_int( ...@@ -81,14 +83,16 @@ xfs_bulkstat_one_int(
ASSERT(ip != NULL); ASSERT(ip != NULL);
ASSERT(ip->i_imap.im_blkno != 0); ASSERT(ip->i_imap.im_blkno != 0);
inode = VFS_I(ip); inode = VFS_I(ip);
vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
/* xfs_iget returns the following without needing /* xfs_iget returns the following without needing
* further change. * further change.
*/ */
buf->bs_projectid = ip->i_projid; buf->bs_projectid = ip->i_projid;
buf->bs_ino = ino; buf->bs_ino = ino;
buf->bs_uid = from_kuid(sb_userns, i_uid_into_mnt(mnt_userns, inode)); buf->bs_uid = from_kuid(sb_userns, vfsuid_into_kuid(vfsuid));
buf->bs_gid = from_kgid(sb_userns, i_gid_into_mnt(mnt_userns, inode)); buf->bs_gid = from_kgid(sb_userns, vfsgid_into_kgid(vfsgid));
buf->bs_size = ip->i_disk_size; buf->bs_size = ip->i_disk_size;
buf->bs_nlink = inode->i_nlink; buf->bs_nlink = inode->i_nlink;
......
...@@ -226,12 +226,12 @@ xlog_ticket_reservation( ...@@ -226,12 +226,12 @@ xlog_ticket_reservation(
if (head == &log->l_write_head) { if (head == &log->l_write_head) {
ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV); ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV);
return tic->t_unit_res; return tic->t_unit_res;
} else {
if (tic->t_flags & XLOG_TIC_PERM_RESERV)
return tic->t_unit_res * tic->t_cnt;
else
return tic->t_unit_res;
} }
if (tic->t_flags & XLOG_TIC_PERM_RESERV)
return tic->t_unit_res * tic->t_cnt;
return tic->t_unit_res;
} }
STATIC bool STATIC bool
......
...@@ -300,26 +300,28 @@ xfs_validate_new_dalign( ...@@ -300,26 +300,28 @@ xfs_validate_new_dalign(
"alignment check failed: sunit/swidth vs. blocksize(%d)", "alignment check failed: sunit/swidth vs. blocksize(%d)",
mp->m_sb.sb_blocksize); mp->m_sb.sb_blocksize);
return -EINVAL; return -EINVAL;
} else {
/*
* Convert the stripe unit and width to FSBs.
*/
mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
if (mp->m_dalign && (mp->m_sb.sb_agblocks % mp->m_dalign)) {
xfs_warn(mp,
"alignment check failed: sunit/swidth vs. agsize(%d)",
mp->m_sb.sb_agblocks);
return -EINVAL;
} else if (mp->m_dalign) {
mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
} else {
xfs_warn(mp,
"alignment check failed: sunit(%d) less than bsize(%d)",
mp->m_dalign, mp->m_sb.sb_blocksize);
return -EINVAL;
}
} }
/*
* Convert the stripe unit and width to FSBs.
*/
mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
if (mp->m_dalign && (mp->m_sb.sb_agblocks % mp->m_dalign)) {
xfs_warn(mp,
"alignment check failed: sunit/swidth vs. agsize(%d)",
mp->m_sb.sb_agblocks);
return -EINVAL;
}
if (!mp->m_dalign) {
xfs_warn(mp,
"alignment check failed: sunit(%d) less than bsize(%d)",
mp->m_dalign, mp->m_sb.sb_blocksize);
return -EINVAL;
}
mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
if (!xfs_has_dalign(mp)) { if (!xfs_has_dalign(mp)) {
xfs_warn(mp, xfs_warn(mp,
"cannot change alignment: superblock does not support data alignment"); "cannot change alignment: superblock does not support data alignment");
......
...@@ -23,17 +23,18 @@ ...@@ -23,17 +23,18 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/dax.h> #include <linux/dax.h>
struct failure_info { struct xfs_failure_info {
xfs_agblock_t startblock; xfs_agblock_t startblock;
xfs_extlen_t blockcount; xfs_extlen_t blockcount;
int mf_flags; int mf_flags;
bool want_shutdown;
}; };
static pgoff_t static pgoff_t
xfs_failure_pgoff( xfs_failure_pgoff(
struct xfs_mount *mp, struct xfs_mount *mp,
const struct xfs_rmap_irec *rec, const struct xfs_rmap_irec *rec,
const struct failure_info *notify) const struct xfs_failure_info *notify)
{ {
loff_t pos = XFS_FSB_TO_B(mp, rec->rm_offset); loff_t pos = XFS_FSB_TO_B(mp, rec->rm_offset);
...@@ -47,7 +48,7 @@ static unsigned long ...@@ -47,7 +48,7 @@ static unsigned long
xfs_failure_pgcnt( xfs_failure_pgcnt(
struct xfs_mount *mp, struct xfs_mount *mp,
const struct xfs_rmap_irec *rec, const struct xfs_rmap_irec *rec,
const struct failure_info *notify) const struct xfs_failure_info *notify)
{ {
xfs_agblock_t end_rec; xfs_agblock_t end_rec;
xfs_agblock_t end_notify; xfs_agblock_t end_notify;
...@@ -71,13 +72,13 @@ xfs_dax_failure_fn( ...@@ -71,13 +72,13 @@ xfs_dax_failure_fn(
{ {
struct xfs_mount *mp = cur->bc_mp; struct xfs_mount *mp = cur->bc_mp;
struct xfs_inode *ip; struct xfs_inode *ip;
struct failure_info *notify = data; struct xfs_failure_info *notify = data;
int error = 0; int error = 0;
if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) ||
(rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) { (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) {
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_ONDISK); notify->want_shutdown = true;
return -EFSCORRUPTED; return 0;
} }
/* Get files that incore, filter out others that are not in use. */ /* Get files that incore, filter out others that are not in use. */
...@@ -86,8 +87,10 @@ xfs_dax_failure_fn( ...@@ -86,8 +87,10 @@ xfs_dax_failure_fn(
/* Continue the rmap query if the inode isn't incore */ /* Continue the rmap query if the inode isn't incore */
if (error == -ENODATA) if (error == -ENODATA)
return 0; return 0;
if (error) if (error) {
return error; notify->want_shutdown = true;
return 0;
}
error = mf_dax_kill_procs(VFS_I(ip)->i_mapping, error = mf_dax_kill_procs(VFS_I(ip)->i_mapping,
xfs_failure_pgoff(mp, rec, notify), xfs_failure_pgoff(mp, rec, notify),
...@@ -104,6 +107,7 @@ xfs_dax_notify_ddev_failure( ...@@ -104,6 +107,7 @@ xfs_dax_notify_ddev_failure(
xfs_daddr_t bblen, xfs_daddr_t bblen,
int mf_flags) int mf_flags)
{ {
struct xfs_failure_info notify = { .mf_flags = mf_flags };
struct xfs_trans *tp = NULL; struct xfs_trans *tp = NULL;
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
struct xfs_buf *agf_bp = NULL; struct xfs_buf *agf_bp = NULL;
...@@ -120,7 +124,6 @@ xfs_dax_notify_ddev_failure( ...@@ -120,7 +124,6 @@ xfs_dax_notify_ddev_failure(
for (; agno <= end_agno; agno++) { for (; agno <= end_agno; agno++) {
struct xfs_rmap_irec ri_low = { }; struct xfs_rmap_irec ri_low = { };
struct xfs_rmap_irec ri_high; struct xfs_rmap_irec ri_high;
struct failure_info notify;
struct xfs_agf *agf; struct xfs_agf *agf;
xfs_agblock_t agend; xfs_agblock_t agend;
struct xfs_perag *pag; struct xfs_perag *pag;
...@@ -161,6 +164,11 @@ xfs_dax_notify_ddev_failure( ...@@ -161,6 +164,11 @@ xfs_dax_notify_ddev_failure(
} }
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
if (error || notify.want_shutdown) {
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_ONDISK);
if (!error)
error = -EFSCORRUPTED;
}
return error; return error;
} }
......
...@@ -200,7 +200,9 @@ xfs_reflink_trim_around_shared( ...@@ -200,7 +200,9 @@ xfs_reflink_trim_around_shared(
if (fbno == NULLAGBLOCK) { if (fbno == NULLAGBLOCK) {
/* No shared blocks at all. */ /* No shared blocks at all. */
return 0; return 0;
} else if (fbno == agbno) { }
if (fbno == agbno) {
/* /*
* The start of this extent is shared. Truncate the * The start of this extent is shared. Truncate the
* mapping at the end of the shared region so that a * mapping at the end of the shared region so that a
...@@ -210,16 +212,16 @@ xfs_reflink_trim_around_shared( ...@@ -210,16 +212,16 @@ xfs_reflink_trim_around_shared(
irec->br_blockcount = flen; irec->br_blockcount = flen;
*shared = true; *shared = true;
return 0; return 0;
} else {
/*
* There's a shared extent midway through this extent.
* Truncate the mapping at the start of the shared
* extent so that a subsequent iteration starts at the
* start of the shared region.
*/
irec->br_blockcount = fbno - agbno;
return 0;
} }
/*
* There's a shared extent midway through this extent.
* Truncate the mapping at the start of the shared
* extent so that a subsequent iteration starts at the
* start of the shared region.
*/
irec->br_blockcount = fbno - agbno;
return 0;
} }
int int
......
...@@ -74,7 +74,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) ...@@ -74,7 +74,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
defer_relog += per_cpu_ptr(stats, i)->s.defer_relog; defer_relog += per_cpu_ptr(stats, i)->s.defer_relog;
} }
len += scnprintf(buf + len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n", len += scnprintf(buf + len, PATH_MAX-len, "xpc %llu %llu %llu\n",
xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
len += scnprintf(buf + len, PATH_MAX-len, "defer_relog %llu\n", len += scnprintf(buf + len, PATH_MAX-len, "defer_relog %llu\n",
defer_relog); defer_relog);
...@@ -125,7 +125,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v) ...@@ -125,7 +125,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v)
{ {
int j; int j;
seq_printf(m, "qm"); seq_puts(m, "qm");
for (j = XFSSTAT_START_XQMSTAT; j < XFSSTAT_END_XQMSTAT; j++) for (j = XFSSTAT_START_XQMSTAT; j < XFSSTAT_END_XQMSTAT; j++)
seq_printf(m, " %u", counter_val(xfsstats.xs_stats, j)); seq_printf(m, " %u", counter_val(xfsstats.xs_stats, j));
seq_putc(m, '\n'); seq_putc(m, '\n');
......
...@@ -1170,7 +1170,7 @@ DECLARE_EVENT_CLASS(xfs_dqtrx_class, ...@@ -1170,7 +1170,7 @@ DECLARE_EVENT_CLASS(xfs_dqtrx_class,
__entry->ino_res_used = qtrx->qt_ino_res_used; __entry->ino_res_used = qtrx->qt_ino_res_used;
__entry->icount_delta = qtrx->qt_icount_delta; __entry->icount_delta = qtrx->qt_icount_delta;
), ),
TP_printk("dev %d:%d dquot id 0x%x type %s flags %s" TP_printk("dev %d:%d dquot id 0x%x type %s flags %s "
"blk_res %llu bcount_delta %lld delbcnt_delta %lld " "blk_res %llu bcount_delta %lld delbcnt_delta %lld "
"rtblk_res %llu rtblk_res_used %llu rtbcount_delta %lld delrtb_delta %lld " "rtblk_res %llu rtblk_res_used %llu rtbcount_delta %lld delrtb_delta %lld "
"ino_res %llu ino_res_used %llu icount_delta %lld", "ino_res %llu ino_res_used %llu icount_delta %lld",
...@@ -1602,7 +1602,7 @@ TRACE_EVENT(xfs_bunmap, ...@@ -1602,7 +1602,7 @@ TRACE_EVENT(xfs_bunmap,
__entry->caller_ip = caller_ip; __entry->caller_ip = caller_ip;
__entry->flags = flags; __entry->flags = flags;
), ),
TP_printk("dev %d:%d ino 0x%llx disize 0x%llx fileoff 0x%llx fsbcount 0x%llx" TP_printk("dev %d:%d ino 0x%llx disize 0x%llx fileoff 0x%llx fsbcount 0x%llx "
"flags %s caller %pS", "flags %s caller %pS",
MAJOR(__entry->dev), MINOR(__entry->dev), MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->ino,
......
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