Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_vnops.c.sav3
Show First 20 Lines • Show All 3,003 Lines • ▼ Show 20 Lines | vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, | ||||
struct vattr va; | struct vattr va; | ||||
struct mount *mp; | struct mount *mp; | ||||
struct uio io; | struct uio io; | ||||
off_t startoff, endoff, xfer, xfer2; | off_t startoff, endoff, xfer, xfer2; | ||||
u_long blksize; | u_long blksize; | ||||
int error; | int error; | ||||
bool cantseek, readzeros, eof, lastblock; | bool cantseek, readzeros, eof, lastblock; | ||||
ssize_t aresid; | ssize_t aresid; | ||||
size_t copylen, len, savlen; | size_t copylen, len, rem, savlen; | ||||
char *dat; | char *dat; | ||||
long holein, holeout; | long holein, holeout; | ||||
uint64_t curtime, stoptime; | uint64_t curtime, stoptime; | ||||
struct timespec tm; | struct timespec tm; | ||||
nanouptime(&tm); | nanouptime(&tm); | ||||
stoptime = tm.tv_sec + 1; | stoptime = tm.tv_sec + 1; | ||||
stoptime = stoptime * 1000000 + tm.tv_nsec / 1000; | stoptime = stoptime * 1000000 + tm.tv_nsec / 1000; | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* Set the blksize to the larger of the hole sizes for invp and outvp. | * Set the blksize to the larger of the hole sizes for invp and outvp. | ||||
* If hole sizes aren't available, set the blksize to the larger | * If hole sizes aren't available, set the blksize to the larger | ||||
* f_iosize of invp and outvp. | * f_iosize of invp and outvp. | ||||
* This code expects the hole sizes and f_iosizes to be powers of 2. | * This code expects the hole sizes and f_iosizes to be powers of 2. | ||||
* This value is clipped at 4Kbytes and 1Mbyte. | * This value is clipped at 4Kbytes and 1Mbyte. | ||||
*/ | */ | ||||
blksize = MAX(holein, holeout); | blksize = MAX(holein, holeout); | ||||
/* Clip len to end at an exact multiple of hole size. */ | |||||
if (blksize > 0) { | |||||
asomers: According to pathconf(2), `_PC_MIN_HOLE_SIZE` has a special meaning for 1. So that's probably… | |||||
rem = *inoffp % blksize; | |||||
Done Inline ActionsThis expression is also defined as rounddown(len, blksize). asomers: This expression is also defined as `rounddown(len, blksize)`. | |||||
if (rem > 0) | |||||
rem = blksize - rem; | |||||
if (len - rem > blksize) | |||||
len = rounddown(len - rem, blksize) + rem; | |||||
} | |||||
if (blksize == 0) | if (blksize == 0) | ||||
blksize = MAX(invp->v_mount->mnt_stat.f_iosize, | blksize = MAX(invp->v_mount->mnt_stat.f_iosize, | ||||
outvp->v_mount->mnt_stat.f_iosize); | outvp->v_mount->mnt_stat.f_iosize); | ||||
if (blksize < 4096) | if (blksize < 4096) | ||||
blksize = 4096; | blksize = 4096; | ||||
else if (blksize > 1024 * 1024) | else if (blksize > 1024 * 1024) | ||||
blksize = 1024 * 1024; | blksize = 1024 * 1024; | ||||
dat = malloc(blksize, M_TEMP, M_WAITOK); | dat = malloc(blksize, M_TEMP, M_WAITOK); | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |
According to pathconf(2), _PC_MIN_HOLE_SIZE has a special meaning for 1. So that's probably a common value. You can optimize this block by changing the test to if (blksize > 1)