# define __USE_ISOC99 1
# include <stdbool.h>
# include <stdio.h> /* snprintf() */
+# include <stdlib.h> /* abs() */
+# include <errno.h>
# include <sys/stat.h>
# define __USE_GNU 1
return CLF_GET_BITS(clf_flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L);
}
-static inline void hsm_set_cl_error(enum changelog_rec_flags *clf_flags,
- unsigned int error)
+static inline int hsm_set_cl_error(enum changelog_rec_flags *clf_flags,
+ int error)
{
+ /* In case a negative error is given */
+ error = abs(error);
+
+ if (error > CLF_HSM_MAXERROR)
+ error = CLF_HSM_ERROVERFLOW;
+
*clf_flags = (enum changelog_rec_flags)
(*clf_flags | (error << CLF_HSM_ERR_L));
+
+ return error == CLF_HSM_ERROVERFLOW ? -EOVERFLOW : 0;
}
enum changelog_rec_extra_flags {
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/kthread.h>
+#include <linux/kernel.h>
#include <obd_support.h>
#include <lustre_export.h>
#include <obd.h>
break;
}
- if (pgs->hpk_errval > CLF_HSM_MAXERROR) {
- CERROR("%s: Request %#llx on "DFID
- " failed, error code %d too large\n",
- mdt_obd_name(mdt),
- pgs->hpk_cookie, PFID(&pgs->hpk_fid),
- pgs->hpk_errval);
- hsm_set_cl_error(&clf_flags, CLF_HSM_ERROVERFLOW);
- rc = -EINVAL;
- } else {
- hsm_set_cl_error(&clf_flags, pgs->hpk_errval);
+ rc = hsm_set_cl_error(&clf_flags, pgs->hpk_errval);
+ if (rc == -EOVERFLOW) {
+ CERROR("%s: Request %#llx on "DFID" failed, error code %d too large\n",
+ mdt_obd_name(mdt), pgs->hpk_cookie,
+ PFID(&pgs->hpk_fid), (int)abs(pgs->hpk_errval));
+ rc = 0;
}
switch (car->car_hai->hai_action) {
if (cdt->cdt_policy & CDT_NORETRY_ACTION)
*status = ARS_FAILED;
pgs->hpk_errval = -rc;
+ hsm_set_cl_error(&clf_flags, pgs->hpk_errval);
}
}
/* we have to retry, so keep layout lock */