smaUtil.c 1.7 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "sma.h"
17
#include "vnd.h"
C
Cary Xu 已提交
18

K
kailixu 已提交
19
void tdRSmaQTaskInfoGetFullPath(SVnode *pVnode, tb_uid_t suid, int8_t level, STfs *pTfs, char *outputName) {
20
  tdRSmaGetDirName(pVnode, pTfs, true, outputName);
K
kailixu 已提交
21
  int32_t rsmaLen = strlen(outputName);
K
kailixu 已提交
22
  snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8 "%s%" PRIi64, level, TD_DIRSEP, suid);
23 24
}

25 26 27 28
void tdRSmaGetDirName(SVnode *pVnode, STfs *pTfs, bool endWithSep, char *outputName) {
  int32_t offset = 0;

  // vnode
29
  vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pTfs, outputName, TSDB_FILENAME_LEN);
30 31 32 33 34
  offset = strlen(outputName);

  // rsma
  snprintf(outputName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s%s", TD_DIRSEP, VNODE_RSMA_DIR,
           (endWithSep ? TD_DIRSEP : ""));
C
Cary Xu 已提交
35
}
C
Cary Xu 已提交
36

C
Cary Xu 已提交
37
// smaXXXUtil ================
K
kailixu 已提交
38
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { return taosAcquireRef(rsetId, refId); }
C
Cary Xu 已提交
39

C
Cary Xu 已提交
40
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
C
Cary Xu 已提交
41
  if (taosReleaseRef(rsetId, refId) < 0) {
C
Cary Xu 已提交
42
    smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
C
Cary Xu 已提交
43 44 45 46
    return TSDB_CODE_FAILED;
  }

  return TSDB_CODE_SUCCESS;
47
}