lustre_log.h

来自「lustre 1.6.5 source code」· C头文件 代码 · 共 484 行 · 第 1/2 页

H
484
字号
        if (a.mnt_cnt < b.mnt_cnt)                return 1;        if (a.mnt_cnt > b.mnt_cnt)                return 0;        return(a.conn_cnt < b.conn_cnt ? 1 : 0);}#define LLOG_GEN_INC(gen)  ((gen).conn_cnt ++)#define LLOG_PROC_BREAK 0x0001#define LLOG_DEL_RECORD 0x0002static inline int llog_obd2ops(struct llog_ctxt *ctxt,                               struct llog_operations **lop){        if (ctxt == NULL)                return -ENOTCONN;        *lop = ctxt->loc_logops;        if (*lop == NULL)                return -EOPNOTSUPP;        return 0;}static inline int llog_handle2ops(struct llog_handle *loghandle,                                  struct llog_operations **lop){        if (loghandle == NULL)                return -EINVAL;        return llog_obd2ops(loghandle->lgh_ctxt, lop);}static inline int llog_data_len(int len){        return size_round(len);}#define llog_ctxt_get(ctxt)                                                 \({                                                                          \         struct llog_ctxt *ctxt_ = ctxt;                                    \         LASSERT(atomic_read(&ctxt_->loc_refcount) > 0);                    \         atomic_inc(&ctxt_->loc_refcount);                                  \         CDEBUG(D_INFO, "GETting ctxt %p : new refcount %d\n", ctxt_,       \                atomic_read(&ctxt_->loc_refcount));                         \         ctxt_;                                                             \}) #define llog_ctxt_put(ctxt)                                                 \do {                                                                        \         if ((ctxt) == NULL)                                                \                 break;                                                     \         CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", (ctxt),      \                atomic_read(&(ctxt)->loc_refcount) - 1);                    \         LASSERT(atomic_read(&(ctxt)->loc_refcount) > 0);                   \         LASSERT(atomic_read(&(ctxt)->loc_refcount) < 0x5a5a5a);            \         __llog_ctxt_put(ctxt);                                             \} while (0)static inline struct llog_ctxt *llog_get_context(struct obd_device *obd,                                                   int index){         struct llog_ctxt *ctxt;          if (index < 0 || index >= LLOG_MAX_CTXTS)                 return NULL;                 spin_lock(&obd->obd_dev_lock);           if (obd->obd_llog_ctxt[index] == NULL) {                 spin_unlock(&obd->obd_dev_lock);                 CDEBUG(D_INFO, "obd %p and ctxt index %d is NULL \n", obd, index);                 return NULL;         }         ctxt = llog_ctxt_get(obd->obd_llog_ctxt[index]);         spin_unlock(&obd->obd_dev_lock);         return ctxt;}static inline int llog_ctxt_null(struct obd_device *obd, int index){        return (obd->obd_llog_ctxt[index] == NULL);}static inline int llog_write_rec(struct llog_handle *handle,                                 struct llog_rec_hdr *rec,                                 struct llog_cookie *logcookies,                                 int numcookies, void *buf, int idx){        struct llog_operations *lop;        __u32 cap;        int rc, buflen;        ENTRY;        rc = llog_handle2ops(handle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_write_rec == NULL)                RETURN(-EOPNOTSUPP);        if (buf)                buflen = rec->lrh_len + sizeof(struct llog_rec_hdr)                                + sizeof(struct llog_rec_tail);        else                buflen = rec->lrh_len;        LASSERT(size_round(buflen) == buflen);        cap = current->cap_effective;                     cap_raise(current->cap_effective, CAP_SYS_RESOURCE);         rc = lop->lop_write_rec(handle, rec, logcookies, numcookies, buf, idx);        current->cap_effective = cap;         RETURN(rc);}static inline int llog_read_header(struct llog_handle *handle){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_handle2ops(handle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_read_header == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_read_header(handle);        RETURN(rc);}static inline int llog_destroy(struct llog_handle *handle){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_handle2ops(handle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_destroy == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_destroy(handle);        RETURN(rc);}#if 0static inline int llog_cancel(struct obd_export *exp,                              struct lov_stripe_md *lsm, int count,                              struct llog_cookie *cookies, int flags){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_handle2ops(loghandle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_cancel == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_cancel(exp, lsm, count, cookies, flags);        RETURN(rc);}#endifstatic inline int llog_next_block(struct llog_handle *loghandle, int *cur_idx,                                  int next_idx, __u64 *cur_offset, void *buf,                                  int len){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_handle2ops(loghandle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_next_block == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_next_block(loghandle, cur_idx, next_idx, cur_offset, buf,                                 len);        RETURN(rc);}static inline int llog_prev_block(struct llog_handle *loghandle,                                  int prev_idx, void *buf, int len){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_handle2ops(loghandle, &lop);        if (rc)                RETURN(rc);        if (lop->lop_prev_block == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_prev_block(loghandle, prev_idx, buf, len);        RETURN(rc);}static inline int llog_create(struct llog_ctxt *ctxt, struct llog_handle **res,                              struct llog_logid *logid, char *name){        struct llog_operations *lop;        __u32 cap;        int rc;        ENTRY;        rc = llog_obd2ops(ctxt, &lop);        if (rc)                RETURN(rc);        if (lop->lop_create == NULL)                RETURN(-EOPNOTSUPP);        cap = current->cap_effective;                     cap_raise(current->cap_effective, CAP_SYS_RESOURCE);        rc = lop->lop_create(ctxt, res, logid, name);        current->cap_effective = cap;         RETURN(rc);}static inline int llog_connect(struct llog_ctxt *ctxt, int count,                               struct llog_logid *logid, struct llog_gen *gen,                               struct obd_uuid *uuid){        struct llog_operations *lop;        int rc;        ENTRY;        rc = llog_obd2ops(ctxt, &lop);        if (rc)                RETURN(rc);        if (lop->lop_connect == NULL)                RETURN(-EOPNOTSUPP);        rc = lop->lop_connect(ctxt, count, logid, gen, uuid);        RETURN(rc);}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?