/* Convert an fsmap owner into an rmapbt owner. */ staticint
xfs_fsmap_owner_to_rmap( struct xfs_rmap_irec *dest, conststruct xfs_fsmap *src)
{ if (!(src->fmr_flags & FMR_OF_SPECIAL_OWNER)) {
dest->rm_owner = src->fmr_owner; return 0;
}
switch (src->fmr_owner) { case 0: /* "lowest owner id possible" */ case -1ULL: /* "highest owner id possible" */
dest->rm_owner = src->fmr_owner; break; case XFS_FMR_OWN_FREE:
dest->rm_owner = XFS_RMAP_OWN_NULL; break; case XFS_FMR_OWN_UNKNOWN:
dest->rm_owner = XFS_RMAP_OWN_UNKNOWN; break; case XFS_FMR_OWN_FS:
dest->rm_owner = XFS_RMAP_OWN_FS; break; case XFS_FMR_OWN_LOG:
dest->rm_owner = XFS_RMAP_OWN_LOG; break; case XFS_FMR_OWN_AG:
dest->rm_owner = XFS_RMAP_OWN_AG; break; case XFS_FMR_OWN_INOBT:
dest->rm_owner = XFS_RMAP_OWN_INOBT; break; case XFS_FMR_OWN_INODES:
dest->rm_owner = XFS_RMAP_OWN_INODES; break; case XFS_FMR_OWN_REFC:
dest->rm_owner = XFS_RMAP_OWN_REFC; break; case XFS_FMR_OWN_COW:
dest->rm_owner = XFS_RMAP_OWN_COW; break; case XFS_FMR_OWN_DEFECTIVE: /* not implemented */ /* fall through */ default: return -EINVAL;
} return 0;
}
/* Convert an rmapbt owner into an fsmap owner. */ staticint
xfs_fsmap_owner_from_frec( struct xfs_fsmap *dest, conststruct xfs_fsmap_irec *frec)
{
dest->fmr_flags = 0; if (!XFS_RMAP_NON_INODE_OWNER(frec->owner)) {
dest->fmr_owner = frec->owner; return 0;
}
dest->fmr_flags |= FMR_OF_SPECIAL_OWNER;
switch (frec->owner) { case XFS_RMAP_OWN_FS:
dest->fmr_owner = XFS_FMR_OWN_FS; break; case XFS_RMAP_OWN_LOG:
dest->fmr_owner = XFS_FMR_OWN_LOG; break; case XFS_RMAP_OWN_AG:
dest->fmr_owner = XFS_FMR_OWN_AG; break; case XFS_RMAP_OWN_INOBT:
dest->fmr_owner = XFS_FMR_OWN_INOBT; break; case XFS_RMAP_OWN_INODES:
dest->fmr_owner = XFS_FMR_OWN_INODES; break; case XFS_RMAP_OWN_REFC:
dest->fmr_owner = XFS_FMR_OWN_REFC; break; case XFS_RMAP_OWN_COW:
dest->fmr_owner = XFS_FMR_OWN_COW; break; case XFS_RMAP_OWN_NULL: /* "free" */
dest->fmr_owner = XFS_FMR_OWN_FREE; break; default:
ASSERT(0); return -EFSCORRUPTED;
} return 0;
}
/* getfsmap query state */ struct xfs_getfsmap_info { struct xfs_fsmap_head *head; struct fsmap *fsmap_recs; /* mapping records */ struct xfs_buf *agf_bp; /* AGF, for refcount queries */ struct xfs_group *group; /* group info, if applicable */
xfs_daddr_t next_daddr; /* next daddr we expect */ /* daddr of low fsmap key when we're using the rtbitmap */
xfs_daddr_t low_daddr; /* daddr of high fsmap key, or the last daddr on the device */
xfs_daddr_t end_daddr;
u64 missing_owner; /* owner of holes */
u32 dev; /* device id */ /* * Low rmap key for the query. If low.rm_blockcount is nonzero, this * is the second (or later) call to retrieve the recordset in pieces. * xfs_getfsmap_rec_before_start will compare all records retrieved * by the rmapbt query to filter out any records that start before * the last record.
*/ struct xfs_rmap_irec low; struct xfs_rmap_irec high; /* high rmap key */ bool last; /* last extent? */
};
/* Associate a device with a getfsmap handler. */ struct xfs_getfsmap_dev {
u32 dev; int (*fn)(struct xfs_trans *tp, conststruct xfs_fsmap *keys, struct xfs_getfsmap_info *info);
sector_t nr_sectors;
};
/* Decide if this mapping is shared. */ STATICint
xfs_getfsmap_is_shared( struct xfs_trans *tp, struct xfs_getfsmap_info *info, conststruct xfs_fsmap_irec *frec, bool *stat)
{ struct xfs_mount *mp = tp->t_mountp; struct xfs_btree_cur *cur;
xfs_agblock_t fbno;
xfs_extlen_t flen = 0; int error;
*stat = false; if (!xfs_has_reflink(mp) || !info->group) return 0;
if (info->group->xg_type == XG_TYPE_RTG)
cur = xfs_rtrefcountbt_init_cursor(tp, to_rtg(info->group)); else
cur = xfs_refcountbt_init_cursor(mp, tp, info->agf_bp,
to_perag(info->group));
/* Are there any shared blocks here? */
error = xfs_refcount_find_shared(cur, frec->rec_key,
XFS_BB_TO_FSBT(mp, frec->len_daddr), &fbno, &flen, false);
xfs_btree_del_cursor(cur, error); if (error) return error;
/* * Format a reverse mapping for getfsmap, having translated rm_startblock * into the appropriate daddr units. Pass in a nonzero @len_daddr if the * length could be larger than rm_blockcount in struct xfs_rmap_irec.
*/ STATICint
xfs_getfsmap_helper( struct xfs_trans *tp, struct xfs_getfsmap_info *info, conststruct xfs_fsmap_irec *frec)
{ struct xfs_fsmap fmr; struct xfs_mount *mp = tp->t_mountp; bool shared; int error = 0;
if (fatal_signal_pending(current)) return -EINTR;
/* * Filter out records that start before our startpoint, if the * caller requested that.
*/ if (xfs_getfsmap_frec_before_start(info, frec)) goto out;
/* Are we just counting mappings? */ if (info->head->fmh_count == 0) { if (info->head->fmh_entries == UINT_MAX) return -ECANCELED;
if (frec->start_daddr > info->next_daddr)
info->head->fmh_entries++;
if (info->last) return 0;
info->head->fmh_entries++; goto out;
}
/* * If the record starts past the last physical block we saw, * then we've found a gap. Report the gap as being owned by * whatever the caller specified is the missing owner.
*/ if (frec->start_daddr > info->next_daddr) { if (info->head->fmh_entries >= info->head->fmh_count) return -ECANCELED;
staticinlineint
xfs_getfsmap_group_helper( struct xfs_getfsmap_info *info, struct xfs_trans *tp, struct xfs_group *xg,
xfs_agblock_t startblock,
xfs_extlen_t blockcount, struct xfs_fsmap_irec *frec)
{ /* * For an info->last query, we're looking for a gap between the last * mapping emitted and the high key specified by userspace. If the * user's query spans less than 1 fsblock, then info->high and * info->low will have the same rm_startblock, which causes rec_daddr * and next_daddr to be the same. Therefore, use the end_daddr that * we calculated from userspace's high key to synthesize the record. * Note that if the btree query found a mapping, there won't be a gap.
*/ if (info->last)
frec->start_daddr = info->end_daddr + 1; else
frec->start_daddr = xfs_gbno_to_daddr(xg, startblock);
/* * Convert the fsmap low/high keys to AG based keys. Initialize * low to the fsmap low key and max out the high key to the end * of the AG.
*/
info->low.rm_offset = XFS_BB_TO_FSBT(mp, keys[0].fmr_offset);
error = xfs_fsmap_owner_to_rmap(&info->low, &keys[0]); if (error) return error;
info->low.rm_blockcount = XFS_BB_TO_FSBT(mp, keys[0].fmr_length);
xfs_getfsmap_set_irec_flags(&info->low, &keys[0]);
/* Adjust the low key if we are continuing from where we left off. */ if (info->low.rm_blockcount == 0) { /* No previous record from which to continue */
} elseif (rmap_not_shareable(mp, &info->low)) { /* Last record seen was an unshareable extent */
info->low.rm_owner = 0;
info->low.rm_offset = 0;
start_fsb += info->low.rm_blockcount; if (XFS_FSB_TO_DADDR(mp, start_fsb) >= eofs) return 0;
} else { /* Last record seen was a shareable file data extent */
info->low.rm_offset += info->low.rm_blockcount;
}
info->low.rm_startblock = XFS_FSB_TO_AGBNO(mp, start_fsb);
while ((pag = xfs_perag_next_range(mp, pag, start_ag, end_ag))) { /* * Set the AG high key from the fsmap high key if this * is the last AG that we're querying.
*/
info->group = pag_group(pag); if (pag_agno(pag) == end_ag) {
info->high.rm_startblock = XFS_FSB_TO_AGBNO(mp,
end_fsb);
info->high.rm_offset = XFS_BB_TO_FSBT(mp,
keys[1].fmr_offset);
error = xfs_fsmap_owner_to_rmap(&info->high, &keys[1]); if (error) break;
xfs_getfsmap_set_irec_flags(&info->high, &keys[1]);
}
error = query_fn(tp, info, &bt_cur, priv); if (error) break;
/* * Set the AG low key to the start of the AG prior to * moving on to the next AG.
*/ if (pag_agno(pag) == start_ag)
memset(&info->low, 0, sizeof(info->low));
/* * If this is the last AG, report any gap at the end of it * before we drop the reference to the perag when the loop * terminates.
*/ if (pag_agno(pag) == end_ag) {
info->last = true;
error = query_fn(tp, info, &bt_cur, priv); if (error) break;
}
info->group = NULL;
}
if (bt_cur)
xfs_btree_del_cursor(bt_cur, error < 0 ? XFS_BTREE_ERROR :
XFS_BTREE_NOERROR); if (info->agf_bp) {
xfs_trans_brelse(tp, info->agf_bp);
info->agf_bp = NULL;
} if (info->group) {
xfs_perag_rele(pag);
info->group = NULL;
} elseif (pag) { /* loop termination case */
xfs_perag_rele(pag);
}
return error;
}
/* Actually query the rmap btree. */ STATICint
xfs_getfsmap_datadev_rmapbt_query( struct xfs_trans *tp, struct xfs_getfsmap_info *info, struct xfs_btree_cur **curpp, void *priv)
{ /* Report any gap at the end of the last AG. */ if (info->last) return xfs_getfsmap_rmapbt_helper(*curpp, &info->high, info);
/* Allocate cursor for this AG and query_range it. */
*curpp = xfs_rmapbt_init_cursor(tp->t_mountp, tp, info->agf_bp,
to_perag(info->group)); return xfs_rmap_query_range(*curpp, &info->low, &info->high,
xfs_getfsmap_rmapbt_helper, info);
}
/* Execute a getfsmap query against the regular data device rmapbt. */ STATICint
xfs_getfsmap_datadev_rmapbt( struct xfs_trans *tp, conststruct xfs_fsmap *keys, struct xfs_getfsmap_info *info)
{
info->missing_owner = XFS_FMR_OWN_FREE; return __xfs_getfsmap_datadev(tp, keys, info,
xfs_getfsmap_datadev_rmapbt_query, NULL);
}
/* * For an info->last query, we're looking for a gap between the last * mapping emitted and the high key specified by userspace. If the * user's query spans less than 1 fsblock, then info->high and * info->low will have the same rm_startblock, which causes rec_daddr * and next_daddr to be the same. Therefore, use the end_daddr that * we calculated from userspace's high key to synthesize the record. * Note that if the btree query found a mapping, there won't be a gap.
*/ if (info->last)
frec.start_daddr = info->end_daddr + 1; else
frec.start_daddr = xfs_rtb_to_daddr(mp, start_rtb);
eofs = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks); if (keys[0].fmr_physical >= eofs) return 0;
info->missing_owner = XFS_FMR_OWN_UNKNOWN;
/* Adjust the low key if we are continuing from where we left off. */
start_rtbno = xfs_daddr_to_rtb(mp,
keys[0].fmr_physical + keys[0].fmr_length); if (keys[0].fmr_length > 0) {
info->low_daddr = xfs_rtb_to_daddr(mp, start_rtbno); if (info->low_daddr >= eofs) return 0;
}
start_rtx = xfs_rtb_to_rtx(mp, start_rtbno);
start_rgno = xfs_rtb_to_rgno(mp, start_rtbno);
/* * Report any gaps at the end of the rtbitmap by simulating a * zero-length free extent starting at the rtx after the end * of the query range.
*/ if (rtg_rgno(rtg) == end_rgno) { struct xfs_rtalloc_rec ahigh = {
.ar_startext = min(end_rtx + 1,
rtg->rtg_extents),
};
/* * On zoned filesystems with an internal rt volume, the volume comes * immediately after the end of the data volume. However, the * xfs_rtblock_t address space is relative to the start of the data * device, which means that the first @rtstart fsblocks do not actually * point anywhere. If a fsmap query comes in with the low key starting * below @rtstart, report it as "owned by filesystem".
*/
rtstart_daddr = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart); if (xfs_has_zoned(mp) && key0.fmr_physical < rtstart_daddr) { struct xfs_fsmap_irec frec = {
.owner = XFS_RMAP_OWN_FS,
.len_daddr = rtstart_daddr,
};
/* * Adjust the start of the query range if we're picking up from * a previous round, and only emit the record if we haven't * already gone past.
*/
key0.fmr_physical += key0.fmr_length; if (key0.fmr_physical < rtstart_daddr) {
error = xfs_getfsmap_helper(tp, info, &frec); if (error) return error;
key0.fmr_physical = rtstart_daddr;
}
/* Zero the other fields to avoid further adjustments. */
key0.fmr_owner = 0;
key0.fmr_offset = 0;
key0.fmr_length = 0;
}
/* * Convert the fsmap low/high keys to rtgroup based keys. Initialize * low to the fsmap low key and max out the high key to the end * of the rtgroup.
*/
info->low.rm_offset = XFS_BB_TO_FSBT(mp, key0.fmr_offset);
error = xfs_fsmap_owner_to_rmap(&info->low, &key0); if (error) return error;
info->low.rm_blockcount = XFS_BB_TO_FSBT(mp, key0.fmr_length);
xfs_getfsmap_set_irec_flags(&info->low, &key0);
/* Adjust the low key if we are continuing from where we left off. */ if (info->low.rm_blockcount == 0) { /* No previous record from which to continue */
} elseif (rmap_not_shareable(mp, &info->low)) { /* Last record seen was an unshareable extent */
info->low.rm_owner = 0;
info->low.rm_offset = 0;
start_rtb += info->low.rm_blockcount; if (xfs_rtb_to_daddr(mp, start_rtb) >= eofs) return 0;
} else { /* Last record seen was a shareable file data extent */
info->low.rm_offset += info->low.rm_blockcount;
}
info->low.rm_startblock = xfs_rtb_to_rgbno(mp, start_rtb);
while ((rtg = xfs_rtgroup_next_range(mp, rtg, start_rg, end_rg))) { /* * Set the rtgroup high key from the fsmap high key if this * is the last rtgroup that we're querying.
*/
info->group = rtg_group(rtg); if (rtg_rgno(rtg) == end_rg) {
info->high.rm_startblock =
xfs_rtb_to_rgbno(mp, end_rtb);
info->high.rm_offset =
XFS_BB_TO_FSBT(mp, keys[1].fmr_offset);
error = xfs_fsmap_owner_to_rmap(&info->high, &keys[1]); if (error) break;
xfs_getfsmap_set_irec_flags(&info->high, &keys[1]);
}
error = xfs_getfsmap_rtdev_rmapbt_query(tp, info, &bt_cur); if (error) break;
/* * Set the rtgroup low key to the start of the rtgroup prior to * moving on to the next rtgroup.
*/ if (rtg_rgno(rtg) == start_rg)
memset(&info->low, 0, sizeof(info->low));
/* * If this is the last rtgroup, report any gap at the end of it * before we drop the reference to the perag when the loop * terminates.
*/ if (rtg_rgno(rtg) == end_rg) {
info->last = true;
error = xfs_getfsmap_rtdev_rmapbt_helper(bt_cur,
&info->high, info); if (error) break;
}
info->group = NULL;
}
switch (dev) { case XFS_DEV_DATA: return new_encode_dev(mp->m_ddev_targp->bt_dev); case XFS_DEV_LOG: return new_encode_dev(mp->m_logdev_targp->bt_dev); case XFS_DEV_RT: if (!mp->m_rtdev_targp) break; return new_encode_dev(mp->m_rtdev_targp->bt_dev);
}
/* Ensure that the low key is less than the high key. */ STATICbool
xfs_getfsmap_check_keys( struct xfs_fsmap *low_key, struct xfs_fsmap *high_key)
{ if (low_key->fmr_flags & (FMR_OF_SPECIAL_OWNER | FMR_OF_EXTENT_MAP)) { if (low_key->fmr_offset) returnfalse;
} if (high_key->fmr_flags != -1U &&
(high_key->fmr_flags & (FMR_OF_SPECIAL_OWNER |
FMR_OF_EXTENT_MAP))) { if (high_key->fmr_offset && high_key->fmr_offset != -1ULL) returnfalse;
} if (high_key->fmr_length && high_key->fmr_length != -1ULL) returnfalse;
if (low_key->fmr_device > high_key->fmr_device) returnfalse; if (low_key->fmr_device < high_key->fmr_device) returntrue;
if (low_key->fmr_physical > high_key->fmr_physical) returnfalse; if (low_key->fmr_physical < high_key->fmr_physical) returntrue;
if (low_key->fmr_owner > high_key->fmr_owner) returnfalse; if (low_key->fmr_owner < high_key->fmr_owner) returntrue;
if (low_key->fmr_offset > high_key->fmr_offset) returnfalse; if (low_key->fmr_offset < high_key->fmr_offset) returntrue;
returnfalse;
}
/* * There are only two devices if we didn't configure RT devices at build time.
*/ #ifdef CONFIG_XFS_RT #define XFS_GETFSMAP_DEVS 3 #else #define XFS_GETFSMAP_DEVS 2 #endif/* CONFIG_XFS_RT */
/* * Get filesystem's extents as described in head, and format for output. Fills * in the supplied records array until there are no more reverse mappings to * return or head.fmh_entries == head.fmh_count. In the second case, this * function returns -ECANCELED to indicate that more records would have been * returned. * * Key to Confusion * ---------------- * There are multiple levels of keys and counters at work here: * xfs_fsmap_head.fmh_keys -- low and high fsmap keys passed in; * these reflect fs-wide sector addrs. * dkeys -- fmh_keys used to query each device; * these are fmh_keys but w/ the low key * bumped up by fmr_length. * xfs_getfsmap_info.next_daddr -- next disk addr we expect to see; this * is how we detect gaps in the fsmap records and report them. * xfs_getfsmap_info.low/high -- per-AG low/high keys computed from * dkeys; used to query the metadata.
*/ STATICint
xfs_getfsmap( struct xfs_mount *mp, struct xfs_fsmap_head *head, struct fsmap *fsmap_recs)
{ struct xfs_trans *tp = NULL; struct xfs_fsmap dkeys[2]; /* per-dev keys */ struct xfs_getfsmap_dev handlers[XFS_GETFSMAP_DEVS]; struct xfs_getfsmap_info info = {
.fsmap_recs = fsmap_recs,
.head = head,
}; bool use_rmap; int i; int error = 0;
if (head->fmh_iflags & ~FMH_IF_VALID) return -EINVAL; if (!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[0]) ||
!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[1])) return -EINVAL; if (!xfs_getfsmap_check_keys(&head->fmh_keys[0], &head->fmh_keys[1])) return -EINVAL;
/* Set up our device handlers. */
memset(handlers, 0, sizeof(handlers));
handlers[0].nr_sectors = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks);
handlers[0].dev = xfs_getfsmap_device(mp, XFS_DEV_DATA); if (use_rmap)
handlers[0].fn = xfs_getfsmap_datadev_rmapbt; else
handlers[0].fn = xfs_getfsmap_datadev_bnobt; if (mp->m_logdev_targp != mp->m_ddev_targp) {
handlers[1].nr_sectors = XFS_FSB_TO_BB(mp,
mp->m_sb.sb_logblocks);
handlers[1].dev = xfs_getfsmap_device(mp, XFS_DEV_LOG);
handlers[1].fn = xfs_getfsmap_logdev;
} #ifdef CONFIG_XFS_RT /* * For zoned file systems there is no rtbitmap, so only support fsmap * if the callers is privileged enough to use the full rmap version.
*/ if (mp->m_rtdev_targp && (use_rmap || !xfs_has_zoned(mp))) {
handlers[2].nr_sectors = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks);
handlers[2].dev = xfs_getfsmap_device(mp, XFS_DEV_RT); if (use_rmap)
handlers[2].fn = xfs_getfsmap_rtdev_rmapbt; else
handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap;
} #endif/* CONFIG_XFS_RT */
/* * To continue where we left off, we allow userspace to use the * last mapping from a previous call as the low key of the next. * This is identified by a non-zero length in the low key. We * have to increment the low key in this scenario to ensure we * don't return the same mapping again, and instead return the * very next mapping. * * If the low key mapping refers to file data, the same physical * blocks could be mapped to several other files/offsets. * According to rmapbt record ordering, the minimal next * possible record for the block range is the next starting * offset in the same inode. Therefore, each fsmap backend bumps * the file offset to continue the search appropriately. For * all other low key mapping types (attr blocks, metadata), each * fsmap backend bumps the physical offset as there can be no * other mapping for the same physical block range.
*/
dkeys[0] = head->fmh_keys[0];
memset(&dkeys[1], 0xFF, sizeof(struct xfs_fsmap));
/* For each device we support... */ for (i = 0; i < XFS_GETFSMAP_DEVS; i++) { /* Is this device within the range the user asked for? */ if (!handlers[i].fn) continue; if (head->fmh_keys[0].fmr_device > handlers[i].dev) continue; if (head->fmh_keys[1].fmr_device < handlers[i].dev) break;
/* * If this device number matches the high key, we have to pass * the high key to the handler to limit the query results, and * set the end_daddr so that we can synthesize records at the * end of the query range or device.
*/ if (handlers[i].dev == head->fmh_keys[1].fmr_device) {
dkeys[1] = head->fmh_keys[1];
info.end_daddr = min(handlers[i].nr_sectors - 1,
dkeys[1].fmr_physical);
} else {
info.end_daddr = handlers[i].nr_sectors - 1;
}
/* * If the device number exceeds the low key, zero out the low * key so that we get everything from the beginning.
*/ if (handlers[i].dev > head->fmh_keys[0].fmr_device)
memset(&dkeys[0], 0, sizeof(struct xfs_fsmap));
/* * Grab an empty transaction so that we can use its recursive * buffer locking abilities to detect cycles in the rmapbt * without deadlocking.
*/
tp = xfs_trans_alloc_empty(mp);
/* * For internal RT device we need to report different synthetic devices * for a single physical device, and thus can't report the actual dev_t.
*/ if (!mp->m_sb.sb_rtstart)
head->fmh_oflags = FMH_OF_DEV_T; return error;
}
/* * Use an internal memory buffer so that we don't have to copy fsmap * data to userspace while holding locks. Start by trying to allocate * up to 128k for the buffer, but fall back to a single page if needed.
*/
count = min_t(unsignedint, head.fmh_count,
131072 / sizeof(struct fsmap));
recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL); if (!recs) {
count = min_t(unsignedint, head.fmh_count,
PAGE_SIZE / sizeof(struct fsmap));
recs = kvcalloc(count, sizeof(struct fsmap), GFP_KERNEL); if (!recs) return -ENOMEM;
}
/* Run query, record how many entries we got. */
error = xfs_getfsmap(ip->i_mount, &xhead, recs); switch (error) { case 0: /* * There are no more records in the result set. Copy * whatever we got to userspace and break out.
*/
done = true; break; case -ECANCELED: /* * The internal memory buffer is full. Copy whatever * records we got to userspace and go again if we have * not yet filled the userspace buffer.
*/
error = 0; break; default: goto out_free;
}
head.fmh_entries += xhead.fmh_entries;
head.fmh_oflags = xhead.fmh_oflags;
/* * If the caller wanted a record count or there aren't any * new records to return, we're done.
*/ if (head.fmh_count == 0 || xhead.fmh_entries == 0) break;
/* Copy all the records we got out to userspace. */ if (copy_to_user(user_recs, recs,
xhead.fmh_entries * sizeof(struct fsmap))) {
error = -EFAULT; goto out_free;
}
/* Remember the last record flags we copied to userspace. */
last_rec = &recs[xhead.fmh_entries - 1];
last_flags = last_rec->fmr_flags;
/* Set up the low key for the next iteration. */
xfs_fsmap_to_internal(&xhead.fmh_keys[0], last_rec);
trace_xfs_getfsmap_low_key(ip->i_mount, &xhead.fmh_keys[0]);
} while (!done && head.fmh_entries < head.fmh_count);
/* * If there are no more records in the query result set and we're not * in counting mode, mark the last record returned with the LAST flag.
*/ if (done && head.fmh_count > 0 && head.fmh_entries > 0) { struct fsmap __user *user_rec;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.