X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fliblustreapi_heat.c;fp=lustre%2Futils%2Fliblustreapi_heat.c;h=b7034449e2c8273242125f7a98cf7284a1ffcac5;hb=ae723cf8161f7af15fb7c2541fa7d4131a816af9;hp=0000000000000000000000000000000000000000;hpb=7eb7f852ba4cb642ef0d45842a0dc8cbd6f2024d;p=fs%2Flustre-release.git diff --git a/lustre/utils/liblustreapi_heat.c b/lustre/utils/liblustreapi_heat.c new file mode 100644 index 0000000..b703444 --- /dev/null +++ b/lustre/utils/liblustreapi_heat.c @@ -0,0 +1,78 @@ +/* + * LGPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * (C) Copyright (c) 2018, DataDirect Networks Inc, all rights reserved. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public License + * LGPL version 2.1 or (at your discretion) any later version. + * LGPL version 2.1 accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-2.1.html + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * LGPL HEADER END + */ +/* + * lustre/utils/liblustreapi_heat.c + * + * lustreapi library for heat + * + * Author: Li Xi + */ + +#include +#include +#include + +#include +#include +#include +#include "lustreapi_internal.h" + +/* + * Get heat of a file + * + * \param fd File to get heat. + * \param heat Buffer to save heat. + * + * \retval 0 on success. + * \retval -errno on failure. + */ +int llapi_heat_get(int fd, struct lu_heat *heat) +{ + int rc; + + rc = ioctl(fd, LL_IOC_HEAT_GET, heat); + if (rc < 0) { + llapi_error(LLAPI_MSG_ERROR, -errno, "cannot get heat"); + return -errno; + } + return 0; +} + +/* + * Set heat of a file + * + * \param fd File to get heat. + * \param heat Buffer to save heat. + * + * \retval 0 on success. + * \retval -errno on failure. + */ +int llapi_heat_set(int fd, __u64 flags) +{ + int rc; + + rc = ioctl(fd, LL_IOC_HEAT_SET, &flags); + if (rc < 0) { + llapi_error(LLAPI_MSG_ERROR, -errno, "cannot set heat flags"); + return -errno; + } + return 0; +}