ntfs_read/ntfs_write: use pread/pwrite => 2-8% speed increase (Henk, Szaka)
parent
431ac5d40b
commit
d0a2e7d3a2
|
@ -179,22 +179,18 @@ s64 ntfs_pread(struct ntfs_device *dev, const s64 pos, s64 count, void *b)
|
|||
struct ntfs_device_operations *dops;
|
||||
|
||||
ntfs_log_trace("Entering for pos 0x%llx, count 0x%llx.\n", pos, count);
|
||||
|
||||
if (!b || count < 0 || pos < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
dops = dev->d_ops;
|
||||
/* Locate to position. */
|
||||
if (dops->seek(dev, pos, SEEK_SET) == (off_t)-1) {
|
||||
ntfs_log_perror("ntfs_pread: device seek to 0x%llx returned error",
|
||||
pos);
|
||||
return -1;
|
||||
}
|
||||
/* Read the data. */
|
||||
|
||||
for (total = 0; count; count -= br, total += br) {
|
||||
br = dops->read(dev, (char*)b + total, count);
|
||||
br = dops->pread(dev, (char*)b + total, count, pos + total);
|
||||
/* If everything ok, continue. */
|
||||
if (br > 0)
|
||||
continue;
|
||||
|
@ -244,16 +240,13 @@ s64 ntfs_pwrite(struct ntfs_device *dev, const s64 pos, s64 count,
|
|||
errno = EROFS;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dops = dev->d_ops;
|
||||
/* Locate to position. */
|
||||
if (dops->seek(dev, pos, SEEK_SET) == (off_t)-1) {
|
||||
ntfs_log_perror("ntfs_pwrite: seek to 0x%llx returned error",
|
||||
pos);
|
||||
goto out;
|
||||
}
|
||||
|
||||
NDevSetDirty(dev);
|
||||
for (total = 0; count; count -= written, total += written) {
|
||||
written = dops->write(dev, (const char*)b + total, count);
|
||||
written = dops->pwrite(dev, (const char*)b + total, count,
|
||||
pos + total);
|
||||
/* If everything ok, continue. */
|
||||
if (written > 0)
|
||||
continue;
|
||||
|
|
|
@ -239,7 +239,7 @@ static s64 ntfs_device_unix_io_write(struct ntfs_device *dev, const void *buf,
|
|||
static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf,
|
||||
s64 count, s64 offset)
|
||||
{
|
||||
return ntfs_pread(dev, offset, count, buf);
|
||||
return pread(DEV_FD(dev), buf, count, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +261,7 @@ static s64 ntfs_device_unix_io_pwrite(struct ntfs_device *dev, const void *buf,
|
|||
return -1;
|
||||
}
|
||||
NDevSetDirty(dev);
|
||||
return ntfs_pwrite(dev, offset, count, buf);
|
||||
return pwrite(DEV_FD(dev), buf, count, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue