Whamcloud - gitweb
Initial versions of Peter's commit logs/daemon code.
authoradilger <adilger>
Wed, 16 Apr 2003 19:58:33 +0000 (19:58 +0000)
committeradilger <adilger>
Wed, 16 Apr 2003 19:58:33 +0000 (19:58 +0000)
lustre/include/linux/lustre_commit_confd.h [new file with mode: 0644]
lustre/include/linux/lustre_log.h [new file with mode: 0644]
lustre/mds/commit_confd.c [new file with mode: 0644]

diff --git a/lustre/include/linux/lustre_commit_confd.h b/lustre/include/linux/lustre_commit_confd.h
new file mode 100644 (file)
index 0000000..767d61a
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __LUSTRE_COMMIT_CONFD_H 
+#define __LUSTRE_COMMIT_CONFD_H 
+
+#include <lustre/lustre_log.h>
+
+/*  a commit record that will be sent to an OST for OST trans record cleaning
+ *  or pulled down from the OST for cleaning on the MDS 
+ */
+struct llog_commit_data { 
+        struct llcd_entry; /* connect this data to the import */
+        struct obd_uuid llcd_uuid; /* which node to go to */
+        struct llog_cookie llcd_cookie; 
+}; 
+
+/* the thread data that collects local commits and makes rpc's */
+struct llog_commit_confirm_daeamon { 
+        struct list_head llcconf_list;   /* list of imports with commits */
+        spinlock_t       llcconf_lock;
+        int              llcconf_flags;
+        int              llcconf_highwater;
+        int              llcconf_lowwater;
+};
+
+#endif
diff --git a/lustre/include/linux/lustre_log.h b/lustre/include/linux/lustre_log.h
new file mode 100644 (file)
index 0000000..99a61dd
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef _LUSTRE_LOG_H
+#define _LUSTRE_LOG_H
+
+#include <linux/lustre_lite.h>
+#include <linux/lustre_idl.h>
+#include <linux/obd.h>
+
+/* generic infrastructure for managing a collection of logs. 
+   These logs are used for: 
+
+   - orphan recovery: OST adds record on create
+   - mtime/size consistency: the OST adds a record on first write
+   - open/unlinked objects: OST adds a record on destroy
+
+   - mds unlink log: the MDS adds an entry upon delete
+
+   - raid1 replication log between OST's
+   - MDS replication logs
+*/
+
+/* catalog of log objects */
+
+/* WARNING: adjust size records! */ 
+#define LLOG_SIZE     (64 << 10)  
+#define LLOG_REC_SIZE (1 << 5)
+#define LLOG_ENTRY_COUNT 
+
+struct llog_logid { 
+        __u64           llh_oid;
+        __u64           llh_bootcount;
+};
+
+struct llog_loglist_header { 
+        struct llog_logid  llh_current;
+        char               llh_bitmap[8192];
+        struct llog_logid  llh_logs[0];
+};
+
+
+/* header structure of each log */
+
+/* bitmap of allocated entries is based on minimum entry size of 16
+   bytes with a log file size of 64K that is 16K entries, ie. 16K bits
+   in the bitmap or a 2kb bitmap */
+
+struct llog_header {
+        __u32                 llh_bitmap[1024];
+        __u64                 llh_lastrec; 
+        struct llog_trans_rec llh_records[0];
+};
+
+struct llog_handle { 
+        struct file *llh_file;
+        struct llog_header *llh_hdr;
+        struct llog_logid llh_id; 
+};
+
+/* cookie to find a log entry back */
+struct llog_cookie { 
+        struct llog_logid llc_id; 
+        __u64             llc_recno;
+};
+
+/* OST records for 
+   - orphans
+   - size adjustments
+   - open unlinked files
+*/
+
+struct llog_trans_rec { 
+        __u64             tr_op;
+        struct ll_fid     tr_fid;
+        obd_id            tr_oid;
+};
+
+
+/* exported api prototypes */
+int llog_add_record(struct llog_handle **, void *recbuf, int reclen,
+                    struct llog_cookie *cookie);
+int llog_clear_records(int count, struct llog_cookie **cookies);
+int llog_clear_record(struct llog_handle *handle, __u32 recno);
+int llog_delete(struct llog_logid *id);
+
+/* internal api */
+int llog_id2handle(struct 
+
+#endif
+
diff --git a/lustre/mds/commit_confd.c b/lustre/mds/commit_confd.c
new file mode 100644 (file)
index 0000000..84ced00
--- /dev/null
@@ -0,0 +1,77 @@
+
+
+void commit_add(struct )
+{
+        struct obd_import *import = commit_uuid2import(rec->  uuid);
+
+        if (!import) { 
+                CERROR("unaware of OST UUID %s - dorpping\n", rec-> uuid);
+                EXIT;
+                return;
+        }
+                
+        spin_lock(&import->llcconf_lock);
+        list_add(&rec->  &import); 
+        spin_unlock(&import->llcconf_lock);
+        EXIT;
+        return;
+}
+
+void commit_confd_conf_import(struct obd_import *import, 
+                              struct llog_commit_confirm_daemon *lccd)
+{
+        struct list_head *tmp, *save;
+
+
+        list_for_each_safe(&import->import_cc_list, tmp, save) { 
+                struct llog_commit_data *cd;
+
+                if (atomic_read(import->import_cc_count) <=
+                    lccd->llcconf_lowwater)
+                        break;
+
+                cd = list_entry(tmp, struct llog_commit_data *, llcconf_entry);
+                atomic_dec(&import->import_cc_count);
+                commit_confd_add_and_fire(cd); 
+        }
+        EXIT;
+        return;
+}
+
+
+int commit_confd_main(void *data) 
+{
+        struct llog_commit_confirm_daemon *lccd = data;
+        
+        while (1) { 
+                /* something has happened */
+                event_wait(); 
+
+                if (lccd->flags & LCCD_STOP)
+                        break;
+
+                
+                /* lock llccd imporlist */ 
+                spin_lock(&lccd->llcconf_lock);
+                list_for_each_safe(&lccd->llcconf_list,   ) { 
+                        struct obd_import *import; 
+                        import = list_entry(&lccd->llcconf_list, 
+                                            struct obd_import, 
+                                            import_entry);
+                        get_import(import);
+                        spin_unlock(&lccd->llcconf_lock);
+                        if (atomic_read(import->import_cc_count) > 
+                            lccd->llcconf_highwater)
+                                commit_confd_conf_import(import);
+                        put_import(import);
+                        spin_lock(&lccd->llcconf_lock);
+
+                }
+                spin_unlock(&lccd->llcconf_lock);
+                /* 
+
+        }
+
+        lccd->flags = LCCD_STOPPED;
+        RETURN(0);
+}