int decode_sharing(attribute *pattr, char *name, char *rescn, char *val) { int vns; int rc = 0; /*return code; 0==success*/ if (val == NULL) rc = (PBSE_BADNDATVAL); else { vns = (int) str_to_vnode_sharing(val); if (vns == VNS_UNSET) rc = (PBSE_BADNDATVAL); } if (!rc) { pattr->at_val.at_long = vns; pattr->at_flags |= ATR_VFLAG_SET|ATR_VFLAG_MODIFY|ATR_VFLAG_MODCACHE; } return rc; }
/** * @brief * This function is called from vn_addvnr() before vn_addvnr() inserts a * new name/value pair. If we return zero, the insertion of the given * <ID, name, value> tuple will not occur (but processing of the file * will continue normally); if we return nonzero, the insertion of * the given tuple will occur (and again, processing continues normally). * * Currently we use this function to perform these actions: * * for the "cpus" attribute, build a list of the CPUs belonging * to given vnodes * * for the "mems" attribute, to record the memory node number of * the memory board belonging to a given vnode (note that in * contrast to CPUs, of which there may be more than one, the * model for memory is that of a single (logical) memory board * per vnode) * * for the "sharing" attribute, we simply remember the attribute * value for later use in make_cpuset(), q.v. * * for the "resources_available.mem" attribute, set a flag that * tells us to remember to do the memreserved adjustment * * @param[in] vnid - vnode id * @param[in] attr - attributes * @param[in] attrval - attribute value * * @return int * @retval -1 Failure * @retval 0,1 Success * */ int vn_callback(const char *vnid, char *attr, char *attrval) { static void *ctx = NULL; #if defined(MOM_CPUSET) static char memres[] = "resources_available.mem"; /* * If we're setting the memory on a vnode, turn on a flag telling * us to remember to do the memreserved adjustment. */ if ((do_memreserved_adjustment == 0) && (strcmp(attr, memres) == 0)) { do_memreserved_adjustment = 1; return (1); } #endif /* MOM_CPUSET */ if (strcmp(attr, "cpus") == 0) { mom_vninfo_t *mvp; sprintf(log_buffer, "vnid %s, attr %s, val %s", vnid, attr, attrval); log_event(PBSEVENT_DEBUG3, 0, 0, __func__, log_buffer); if ((ctx == NULL) && ((ctx = new_ctx()) == NULL)) return (-1); if ((mvp = vnid2mominfo(vnid, ctx)) == NULL) return (0); add_CPUlist(mvp, attrval); return (0); } else if (strcmp(attr, "mems") == 0) { mom_vninfo_t *mvp; sprintf(log_buffer, "vnid %s, attr %s, val %s", vnid, attr, attrval); log_event(PBSEVENT_DEBUG3, 0, 0, __func__, log_buffer); if ((ctx == NULL) && ((ctx = new_ctx()) == NULL)) return (-1); if ((mvp = vnid2mominfo(vnid, ctx)) == NULL) return (0); mvp->mvi_memnum = atoi(attrval); #if defined(MOM_CPUSET) && (CPUSET_VERSION >= 4) if (memmask_add(mvp->mvi_memnum) != 0) return (-1); #endif /* MOM_CPUSET && CPUSET_VERSION >= 4 */ return (0); } else if (strcmp(attr, "sharing") == 0) { mom_vninfo_t *mvp; if ((ctx == NULL) && ((ctx = new_ctx()) == NULL)) return (-1); if ((mvp = vnid2mominfo(vnid, ctx)) == NULL) return (0); mvp->mvi_sharing = str_to_vnode_sharing(attrval); return (1); } else return (1); }