aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeebs <seebs@seebs.net>2017-02-01 12:34:50 -0600
committerSeebs <seebs@seebs.net>2017-02-01 12:34:50 -0600
commit02168305b0a19f981ffe857f36eb256ba8810b77 (patch)
treee87002ca2f2ab9dd1fb018948d6c6549112069d6
parent29221601ffba163bad99a8a5ff9eb0d63822c048 (diff)
downloadpseudo-02168305b0a19f981ffe857f36eb256ba8810b77.tar.gz
pseudo-02168305b0a19f981ffe857f36eb256ba8810b77.tar.bz2
pseudo-02168305b0a19f981ffe857f36eb256ba8810b77.zip
don't remove xattrs still in use
When deleting a specific file, delete xattrs only if it's the last file with that device/inode pair. Signed-off-by: Seebs <seebs@seebs.net>
-rw-r--r--ChangeLog.txt3
-rw-r--r--pseudo_db.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index a4bf499..b332296 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2017-02-01:
+ * (seebs) handle xattr deletion slightly more carefully.
+
2016-12-12:
* (seebs) contributed fix to makewrappers (fix space/tab issues)
* (seebs) contributed fixes for Python 3 print support
diff --git a/pseudo_db.c b/pseudo_db.c
index 2008316..a9e294b 100644
--- a/pseudo_db.c
+++ b/pseudo_db.c
@@ -1495,7 +1495,7 @@ pdb_clear_unused_xattrs(void) {
static void
pdb_clear_xattrs(pseudo_msg_t *msg) {
static sqlite3_stmt *delete;
- char *delete_sql = "DELETE FROM xattrs WHERE dev = ? AND ino = ?;";
+ char *delete_sql = "DELETE FROM xattrs WHERE dev = ? AND ino = ? AND (SELECT COUNT(*) FROM files WHERE dev = ? AND ino = ?) = 0;";
int rc;
if (!msg)
@@ -1507,12 +1507,14 @@ pdb_clear_xattrs(pseudo_msg_t *msg) {
if (!delete) {
rc = sqlite3_prepare_v2(file_db, delete_sql, strlen(delete_sql), &delete, NULL);
if (rc) {
- dberr(file_db, "couldn't prepare DELETE statement for unused xattrs");
+ dberr(file_db, "couldn't prepare DELETE statement for specific inode xattrs");
return;
}
}
sqlite3_bind_int(delete, 1, msg->dev);
sqlite3_bind_int(delete, 2, msg->ino);
+ sqlite3_bind_int(delete, 3, msg->dev);
+ sqlite3_bind_int(delete, 4, msg->ino);
rc = sqlite3_step(delete);
if (rc != SQLITE_DONE) {
dberr(file_db, "delete of unused xattrs may have failed");