Revisit st_mtim update handling
Currently, writes to a KIOFuseRemoteCacheBasedFileNode
cause m_stat.st_mtim
to be updated manually.
For some reason (oversight?) this is not the case for RemoteFileJobBasedFileNode
.
With a test case like this:
QTemporaryDir localDir;
QVERIFY(localDir.isValid());
// Mount the temporary dir
QString reply = m_kiofuse_iface.mountUrl(QStringLiteral("file://%1").arg(localDir.path())).value();
QVERIFY(!reply.isEmpty());
QDir mirrorDir(reply);
QVERIFY(mirrorDir.exists());
QByteArray data("Hiya");
data.resize(129308);
// Create a file and directory
QFile file(mirrorDir.filePath(QStringLiteral("file")));
file.open(QFile::ReadWrite);
file.write(data);
file.flush();
file.seek(0);
qDebug() << file.read(4);
file.seek(0);
qDebug() << file.read(4);
it can be seen that the mtime update has a negative side effect: The kernel drops the internal cache:
unique: 30, opcode: WRITE (16), nodeid: 6, insize: 129388, pid: 21499
22:54:22.750 Writing 129308 byte(s) at offset 0 of (cache-based) node "file"
22:54:22.750 Fetching cache for "file"
unique: 30, success, outsize: 24
unique: 32, opcode: GETATTR (3), nodeid: 6, insize: 56, pid: 21499
unique: 32, success, outsize: 120
unique: 34, opcode: READ (15), nodeid: 6, insize: 80, pid: 21499
22:54:22.753 Reading 65536 byte(s) at offset 0 of (cache-based) node "file"
22:54:22.753 Read of "file" done
unique: 34, success, outsize: 65552
QDEBUG : FileOpsTest::testTypeRefresh() 22:54:22.753 "Hiya"
unique: 36, opcode: GETATTR (3), nodeid: 6, insize: 56, pid: 21499
unique: 36, success, outsize: 120
QDEBUG : FileOpsTest::testTypeRefresh() 22:54:22.753 "Hiya"
Doing the same in fileopstest-filejob
has different output:
unique: 30, opcode: WRITE (16), nodeid: 6, insize: 129388, pid: 21522
22:54:58.349 Writing 129308 byte(s) at offset 0 of (FileJob-based) node "file"
unique: 30, success, outsize: 24
unique: 32, opcode: GETATTR (3), nodeid: 6, insize: 56, pid: 21522
unique: 32, success, outsize: 120
QDEBUG : FileOpsTest::testTypeRefresh() 22:54:58.351 "Hiya"
unique: 34, opcode: GETATTR (3), nodeid: 6, insize: 56, pid: 21522
unique: 34, success, outsize: 120
QDEBUG : FileOpsTest::testTypeRefresh() 22:54:58.351 "Hiya"
Disabling the st_mtim
update causes the read to be served completely from the data cached by the preceding write.