Whamcloud - gitweb
- new abstraction in the llog_* function wrappers
authorphil <phil>
Mon, 8 Sep 2003 22:18:37 +0000 (22:18 +0000)
committerphil <phil>
Mon, 8 Sep 2003 22:18:37 +0000 (22:18 +0000)
- fix double-allocation of handle headers
- added llog_read_header()
- more llog tests

lustre/obdclass/llog.c
lustre/obdclass/llog_lvfs.c

index 6b8c64b..803e09a 100644 (file)
@@ -47,11 +47,6 @@ struct llog_handle *llog_alloc_handle(void)
         if (loghandle == NULL)
                 RETURN(ERR_PTR(-ENOMEM));
 
-        OBD_ALLOC(loghandle->lgh_hdr, LLOG_CHUNK_SIZE);
-        if (loghandle->lgh_hdr == NULL) {
-                OBD_FREE(loghandle, sizeof(*loghandle));
-                RETURN(ERR_PTR(-ENOMEM));
-        }
         sema_init(&loghandle->lgh_lock, 1);
 
         RETURN(loghandle);
@@ -110,20 +105,21 @@ int llog_cancel_rec(struct llog_handle *loghandle, int index)
 }
 EXPORT_SYMBOL(llog_cancel_rec);
 
-int llog_init_handle(struct llog_handle *handle, int flags, struct obd_uuid *uuid)
+int llog_init_handle(struct llog_handle *handle, int flags,
+                     struct obd_uuid *uuid)
 {
         int rc; 
         struct llog_log_hdr *llh;
-
+        ENTRY;
         LASSERT(handle->lgh_hdr == NULL);
 
         OBD_ALLOC(llh, sizeof(*llh));
-        if (!llh)
+        if (llh == NULL)
                 RETURN(-ENOMEM);
 
         handle->lgh_hdr = llh;
-        rc = llog_lvfs_read_hdr(handle);
-        if (rc == 0) { 
+        rc = llog_read_header(handle);
+        if (rc == 0) {
                 LASSERT(llh->llh_flags == flags);
                 LASSERT(obd_uuid_equals(uuid, &llh->llh_tgtuuid));
                 RETURN(0);
@@ -149,8 +145,8 @@ int llog_init_handle(struct llog_handle *handle, int flags, struct obd_uuid *uui
         if (rc)
                 OBD_FREE(llh, sizeof(*llh));
         return(rc);
-
 }
+EXPORT_SYMBOL(llog_init_handle);
 
 int llog_process_log(struct llog_handle *loghandle, llog_cb_t cb, void *data)
 {
index 4439f98..8505614 100644 (file)
@@ -324,15 +324,15 @@ static int llog_lvfs_create(struct obd_device *obd, struct llog_handle **res,
         struct llog_handle *handle;
         struct l_dentry *dchild;
         struct obdo *oa = NULL;
-        int rc, cleanup_phase = 1, open_flags = O_RDWR | O_CREAT | O_LARGEFILE;
+        int rc = 0, cleanup_phase = 1;
+        int open_flags = O_RDWR | O_CREAT | O_LARGEFILE;
         ENTRY;
 
         handle = llog_alloc_handle();
-        if (!handle)
+        if (handle == NULL)
                 RETURN(-ENOMEM);
         *res = handle;
 
-
         if (logid != NULL) {
                 dchild = obd_lvfs_fid2dentry(obd->obd_log_exp, logid->lgl_oid,
                                              logid->lgl_ogr);
@@ -363,7 +363,7 @@ static int llog_lvfs_create(struct obd_device *obd, struct llog_handle **res,
         } else if (name) {
                 LASSERT(strlen(name) <= 18);
                 sprintf(logname, "LOGS/%s", name);
-                
+
                 handle->lgh_file = l_filp_open(logname, open_flags, 0644);
                 if (IS_ERR(handle->lgh_file)) {
                         rc = PTR_ERR(handle->lgh_file);
@@ -376,19 +376,21 @@ static int llog_lvfs_create(struct obd_device *obd, struct llog_handle **res,
                         handle->lgh_file->f_dentry->d_inode->i_generation;
         } else {
                 oa = obdo_alloc();
-                if (!oa
+                if (oa == NULL
                         GOTO(cleanup, rc = -ENOMEM);
                 /* XXX */
                 oa->o_gr = 1;
                 oa->o_valid = OBD_MD_FLGROUP;
                 rc = obd_create(obd->obd_log_exp, oa, NULL, NULL);
-                if (rc) 
+                if (rc)
                         GOTO(cleanup, rc);
-                dchild = obd_lvfs_fid2dentry(obd->obd_log_exp, oa->o_id, oa->o_gr);
+                dchild = obd_lvfs_fid2dentry(obd->obd_log_exp, oa->o_id,
+                                             oa->o_gr);
                 if (IS_ERR(dchild))
                         GOTO(cleanup, rc = PTR_ERR(dchild));
                 cleanup_phase = 2;
-                handle->lgh_file = l_dentry_open(&obd->obd_ctxt, dchild, open_flags);
+                handle->lgh_file = l_dentry_open(&obd->obd_ctxt, dchild,
+                                                 open_flags);
                 if (IS_ERR(handle->lgh_file))
                         GOTO(cleanup, rc = PTR_ERR(handle->lgh_file));
                 handle->lgh_id.lgl_oid = oa->o_id;
@@ -408,7 +410,6 @@ cleanup:
         return rc;
 }
 
-
 static int llog_lvfs_close(struct llog_handle *handle)
 {
         int rc;