added migrate time
authorroot <root@hsm1n1.VSOFS1.COM>
Sat, 16 Aug 2008 13:07:52 +0000 (23:07 +1000)
committerroot <root@hsm1n1.VSOFS1.COM>
Sat, 16 Aug 2008 13:07:52 +0000 (23:07 +1000)
README
hacksm.h
hacksm_migrate.c

diff --git a/README b/README
index e71d64bad28a04fa239f0509520317b22133bf2e..4c06111503a1ac1f433616e2e57a7a8b44ebf079 100644 (file)
--- a/README
+++ b/README
@@ -10,3 +10,11 @@ Then start the HSM daemon like this:
 
 You can then migrate files using hacksm_migrate, and view their state
 using hacksm_ls
+
+The "store" for hacksm is just a directory with files named by device
+and inode number. When a file is migrated the data is moved to the
+store and a dmapi hole is punched in the original file. This mimicks
+the behaviour of real HSM daemons. When the hacksmd daemon gets a data
+event (indicating that someone wants to read or write the data in the
+file) then the data is restored from the "store" and the file can then
+be read normally.
index 922265e2edc27ae8c13b8d78935b4f18756ef28a..bd837688559b209f02ecfd6c077ea35f57c78ada 100644 (file)
--- a/hacksm.h
+++ b/hacksm.h
@@ -33,6 +33,7 @@ enum hsm_migrate_state {
 
 struct hsm_attr {
        char magic[4];
+       time_t migrate_time;
        off_t size;
        dev_t device;
        ino_t inode;
index d95958b728f601301ef481698e806ca4f44c3b00..611789e1a05a522d4f5a85fdc4efb8dfecf2d27f 100644 (file)
@@ -89,6 +89,10 @@ static void hsm_migrate(const char *path)
                        exit(1);
                }
                if (h.state == HSM_STATE_START) {
+                       if (h.migrate_time + 60 > time(NULL)) {
+                               printf("Not migrating recent partially migrated file\n");
+                               goto respond;
+                       }
                        printf("Continuing migration of partly migrated file\n");
                        hsm_store_unlink(h.device, h.inode);
                } else {
@@ -137,6 +141,7 @@ static void hsm_migrate(const char *path)
 
        strncpy(h.magic, HSM_MAGIC, sizeof(h.magic));
        h.size = st.st_size;
+       h.migrate_time = time(NULL);
        h.device = st.st_dev;
        h.inode = st.st_ino;
        h.state = HSM_STATE_START;
@@ -159,6 +164,7 @@ static void hsm_migrate(const char *path)
                goto respond;
        }
 
+
        /* we now release the right to let any reads that
           are pending to continue before we destroy the data */
        ret = dm_release_right(dmapi.sid, hanp, hlen, token);
@@ -178,7 +184,7 @@ static void hsm_migrate(const char *path)
        ret = dm_get_dmattr(dmapi.sid, hanp, hlen, token, &attrname, 
                            sizeof(h), &h, &rlen);
        if (ret != 0) {
-               printf("Abandoning partial migrate - attribute gone\n", h.state);
+               printf("Abandoning partial migrate - attribute gone\n");
                goto respond;
        }