Skip to content

Commit

Permalink
chimera: update tags mtime on re-write
Browse files Browse the repository at this point in the history
keep nfs client cache happy

Acked-by: Dmitry Litvintsev
Patch: http://rb.dcache.org/r/5617/
Target: trunk, 2.6, 2.2
Require-book: no
Require-notes: no
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
  • Loading branch information
kofemann committed Jun 5, 2013
1 parent 61cd65d commit 2d993a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Expand Up @@ -1707,7 +1707,7 @@ void assignTagToDir(Connection dbConnection, String tagId, String tagName, FsIno
SqlHelper.tryToClose(ps);
}
}
private static final String sqlSetTag = "UPDATE t_tags_inodes SET ivalue=?, isize=? WHERE itagid=?";
private static final String sqlSetTag = "UPDATE t_tags_inodes SET ivalue=?, isize=?, imtime=? WHERE itagid=?";

int setTag(Connection dbConnection, FsInode inode, String tagName, byte[] data, int offset, int len) throws SQLException, ChimeraFsException {

Expand All @@ -1728,7 +1728,8 @@ int setTag(Connection dbConnection, FsInode inode, String tagName, byte[] data,
stSetTag = dbConnection.prepareStatement(sqlSetTag);
stSetTag.setBinaryStream(1, new ByteArrayInputStream(data, offset, len), len);
stSetTag.setLong(2, len);
stSetTag.setString(3, tagId);
stSetTag.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
stSetTag.setString(4, tagId);
stSetTag.executeUpdate();

} finally {
Expand Down
23 changes: 23 additions & 0 deletions modules/chimera/src/test/java/org/dcache/chimera/BasicTest.java
Expand Up @@ -832,4 +832,27 @@ public void testChangeTagMode() throws Exception {

assertEquals(0007 | UnixPermission.S_IFREG, tagInode.stat().getMode());
}

@Test
public void testUpdateTagMtimeOnWrite() throws Exception {

final String tagName = "myTag";
final byte[] data1 = "some data".getBytes();
final byte[] data2 = "some other data".getBytes();

FsInode base = _rootInode.mkdir("junit");
_fs.createTag(base, tagName);
FsInode tagInode = new FsInode_TAG(_fs, base.toString(), tagName);

tagInode.write(0, data1, 0, data1.length);
Stat statBefore = tagInode.stat();

// unshure that time in millis is changed
TimeUnit.MICROSECONDS.sleep(2);

tagInode.write(0, data2, 0, data2.length);
Stat statAfter = tagInode.stat();

assertTrue(statBefore.getMTime() != statAfter.getMTime());
}
}

0 comments on commit 2d993a3

Please sign in to comment.