forked from Minki/linux
xfs: introduce xfs_aligned_fsb_count
Factor a helper to calculate the extent-size aligned block out of the iomap code, so that it can be reused by the upcoming reflink dio code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
54a4ef8af4
commit
f13eb2055a
|
@ -162,7 +162,7 @@ xfs_iomap_write_direct(
|
||||||
xfs_fileoff_t last_fsb;
|
xfs_fileoff_t last_fsb;
|
||||||
xfs_filblks_t count_fsb, resaligned;
|
xfs_filblks_t count_fsb, resaligned;
|
||||||
xfs_fsblock_t firstfsb;
|
xfs_fsblock_t firstfsb;
|
||||||
xfs_extlen_t extsz, temp;
|
xfs_extlen_t extsz;
|
||||||
int nimaps;
|
int nimaps;
|
||||||
int quota_flag;
|
int quota_flag;
|
||||||
int rt;
|
int rt;
|
||||||
|
@ -203,14 +203,7 @@ xfs_iomap_write_direct(
|
||||||
}
|
}
|
||||||
count_fsb = last_fsb - offset_fsb;
|
count_fsb = last_fsb - offset_fsb;
|
||||||
ASSERT(count_fsb > 0);
|
ASSERT(count_fsb > 0);
|
||||||
|
resaligned = xfs_aligned_fsb_count(offset_fsb, count_fsb, extsz);
|
||||||
resaligned = count_fsb;
|
|
||||||
if (unlikely(extsz)) {
|
|
||||||
if ((temp = do_mod(offset_fsb, extsz)))
|
|
||||||
resaligned += temp;
|
|
||||||
if ((temp = do_mod(resaligned, extsz)))
|
|
||||||
resaligned += extsz - temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(rt)) {
|
if (unlikely(rt)) {
|
||||||
resrtextents = qblocks = resaligned;
|
resrtextents = qblocks = resaligned;
|
||||||
|
|
|
@ -33,6 +33,26 @@ void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
|
||||||
struct xfs_bmbt_irec *);
|
struct xfs_bmbt_irec *);
|
||||||
xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
|
xfs_extlen_t xfs_eof_alignment(struct xfs_inode *ip, xfs_extlen_t extsize);
|
||||||
|
|
||||||
|
static inline xfs_filblks_t
|
||||||
|
xfs_aligned_fsb_count(
|
||||||
|
xfs_fileoff_t offset_fsb,
|
||||||
|
xfs_filblks_t count_fsb,
|
||||||
|
xfs_extlen_t extsz)
|
||||||
|
{
|
||||||
|
if (extsz) {
|
||||||
|
xfs_extlen_t align;
|
||||||
|
|
||||||
|
align = do_mod(offset_fsb, extsz);
|
||||||
|
if (align)
|
||||||
|
count_fsb += align;
|
||||||
|
align = do_mod(count_fsb, extsz);
|
||||||
|
if (align)
|
||||||
|
count_fsb += extsz - align;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count_fsb;
|
||||||
|
}
|
||||||
|
|
||||||
extern const struct iomap_ops xfs_iomap_ops;
|
extern const struct iomap_ops xfs_iomap_ops;
|
||||||
extern const struct iomap_ops xfs_xattr_iomap_ops;
|
extern const struct iomap_ops xfs_xattr_iomap_ops;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user