do_warn(_("would have cleared inode %" PRIu64 "\n"),
ino);
}
+ clear_inode_was_rl(ino_rec, irec_offset);
}
process_next:
if (process_check_inode_forkoff(mp, dino, lino) != 0)
goto clear_bad_out;
+ /*
+ * record the state of the reflink flag
+ */
+ if (collect_rmaps)
+ record_inode_reflink_flag(mp, dino, agno, ino, lino);
+
/*
* check data fork -- if it's bad, clear the inode
*/
__uint64_t ir_sparse; /* sparse inode bitmask */
__uint64_t ino_confirmed; /* confirmed bitmask */
__uint64_t ino_isa_dir; /* bit == 1 if a directory */
+ __uint64_t ino_was_rl; /* bit == 1 if reflink flag set */
+ __uint64_t ino_is_rl; /* bit == 1 if reflink flag should be set */
__uint8_t nlink_size;
union ino_nlink disk_nlinks; /* on-disk nlinks, set in P3 */
union {
return irec->ir_sparse & XFS_INOBT_MASK(offset);
}
+/*
+ * set/clear/test was inode marked as reflinked
+ */
+static inline void set_inode_was_rl(struct ino_tree_node *irec, int offset)
+{
+ irec->ino_was_rl |= IREC_MASK(offset);
+}
+
+static inline void clear_inode_was_rl(struct ino_tree_node *irec, int offset)
+{
+ irec->ino_was_rl &= ~IREC_MASK(offset);
+}
+
+static inline int inode_was_rl(struct ino_tree_node *irec, int offset)
+{
+ return (irec->ino_was_rl & IREC_MASK(offset)) != 0;
+}
+
+/*
+ * set/clear/test should inode be marked as reflinked
+ */
+static inline void set_inode_is_rl(struct ino_tree_node *irec, int offset)
+{
+ irec->ino_is_rl |= IREC_MASK(offset);
+}
+
+static inline void clear_inode_is_rl(struct ino_tree_node *irec, int offset)
+{
+ irec->ino_is_rl &= ~IREC_MASK(offset);
+}
+
+static inline int inode_is_rl(struct ino_tree_node *irec, int offset)
+{
+ return (irec->ino_is_rl & IREC_MASK(offset)) != 0;
+}
+
/*
* add_inode_reached() is set on inode I only if I has been reached
* by an inode P claiming to be the parent and if I is a directory,
irec->ino_startnum = starting_ino;
irec->ino_confirmed = 0;
irec->ino_isa_dir = 0;
+ irec->ino_was_rl = 0;
+ irec->ino_is_rl = 0;
irec->ir_free = (xfs_inofree_t) - 1;
irec->ir_sparse = 0;
irec->ino_un.ex_data = NULL;
key->rm_offset += adj;
}
+/*
+ * Record that an inode had the reflink flag set when repair started. The
+ * inode reflink flag will be adjusted as necessary.
+ */
+void
+record_inode_reflink_flag(
+ struct xfs_mount *mp,
+ struct xfs_dinode *dino,
+ xfs_agnumber_t agno,
+ xfs_agino_t ino,
+ xfs_ino_t lino)
+{
+ struct ino_tree_node *irec;
+ int off;
+
+ ASSERT(XFS_AGINO_TO_INO(mp, agno, ino) == be64_to_cpu(dino->di_ino));
+ if (!(be64_to_cpu(dino->di_flags2) & XFS_DIFLAG2_REFLINK))
+ return;
+ irec = find_inode_rec(mp, agno, ino);
+ off = get_inode_offset(mp, lino, irec);
+ ASSERT(!inode_was_rl(irec, off));
+ set_inode_was_rl(irec, off);
+ dbg_printf("set was_rl lino=%llu was=0x%llx\n",
+ (unsigned long long)lino, (unsigned long long)irec->ino_was_rl);
+}
+
/*
* Regenerate the AGFL so that we don't run out of it while rebuilding the
* rmap btree. If skip_rmapbt is true, don't update the rmapbt (most probably
struct xfs_rmap_irec *key);
extern int compute_refcounts(struct xfs_mount *, xfs_agnumber_t);
+extern void record_inode_reflink_flag(struct xfs_mount *, struct xfs_dinode *,
+ xfs_agnumber_t, xfs_agino_t, xfs_ino_t);
extern void fix_freelist(struct xfs_mount *, xfs_agnumber_t, bool);
extern void rmap_store_agflcount(struct xfs_mount *, xfs_agnumber_t, int);