LASSERT(cache->free_entry);
LASSERT(atomic_read(&entry->ue_refcount) == 0);
- CDEBUG(D_SEC, "destroy %s entry %p for key "LPU64"\n",
+ CDEBUG(D_SEC, "%s: destroy entry %p for key "LPU64"\n",
cache->uc_name, entry, entry->ue_key);
list_del(&entry->ue_hash);
ENTRY;
LASSERT(hash < cache->uc_hashsize);
-
head = &cache->uc_hashtable[hash];
find_again:
/* we're interrupted or upcall failed
* in the middle
*/
- CERROR("entry %p not refreshed: cur %lu, key "LPU64", "
- "ref %d fl %u, ac %ld, ex %ld\n",
- entry, get_seconds(), entry->ue_key,
+ CERROR("%s: entry %p not refreshed: key "LPU64", "
+ "ref %d fl %u, cur %lu, ex %ld/%ld\n",
+ cache->uc_name, entry, entry->ue_key,
atomic_read(&entry->ue_refcount),
- entry->ue_flags, entry->ue_acquire_expire,
- entry->ue_expire);
+ entry->ue_flags, get_seconds(),
+ entry->ue_acquire_expire, entry->ue_expire);
put_entry(entry);
write_unlock(&cache->uc_hashlock);
CERROR("Interrupted? Or check whether %s is in place\n",
write_lock(&cache->uc_hashlock);
LASSERTF(atomic_read(&entry->ue_refcount) > 0,
- "entry %p: ref %d\n", entry, atomic_read(&entry->ue_refcount));
+ "%s: entry %p: ref %d\n", cache->uc_name, entry,
+ atomic_read(&entry->ue_refcount));
put_entry(entry);
write_unlock(&cache->uc_hashlock);
}
if (!found) {
/* haven't found, it's possible */
write_unlock(&cache->uc_hashlock);
- CWARN("key "LPU64" entry dosen't found\n", key);
+ CWARN("%s: key "LPU64" entry dosen't found\n",
+ cache->uc_name, key);
RETURN(-EINVAL);
}
/* This should not happen, just give a warning
* at this moment.
*/
- CWARN("entry %p(key "LPU64", ac %ld, ex %ld): "
- "already valid???\n", entry, entry->ue_key,
+ CWARN("%s: entry %p(key "LPU64", cur %lu, ex %ld/%ld) "
+ "already valid\n", cache->uc_name,
+ entry, entry->ue_key, get_seconds(),
entry->ue_acquire_expire, entry->ue_expire);
GOTO(out, rc = 0);
}
- CWARN("stale entry %p: cur %lu, key "LPU64", ref %d, "
- "fl %u, ac %ld, ex %ld\n",
- entry, get_seconds(), entry->ue_key,
- atomic_read(&entry->ue_refcount), entry->ue_flags,
- entry->ue_acquire_expire, entry->ue_expire);
+ CWARN("%s: stale entry %p: key "LPU64", ref %d, fl %u, "
+ "cur %lu, ex %ld/%ld\n",
+ cache->uc_name, entry, entry->ue_key,
+ atomic_read(&entry->ue_refcount),
+ entry->ue_flags, get_seconds(),
+ entry->ue_acquire_expire, entry->ue_expire);
GOTO(out, rc = -EINVAL);
}
if (!UC_CACHE_IS_ACQUIRING(entry) ||
UC_CACHE_IS_INVALID(entry) ||
UC_CACHE_IS_EXPIRED(entry)) {
- CWARN("stale entry %p: cur %lu, key "LPU64", ref %d, "
- "fl %u, ac %ld, ex %ld\n",
- entry, get_seconds(), entry->ue_key,
- atomic_read(&entry->ue_refcount), entry->ue_flags,
- entry->ue_acquire_expire, entry->ue_expire);
+ CWARN("%s: invalid entry %p: key "LPU64", ref %d, fl %u, "
+ "cur %lu, ex %ld/%ld\n",
+ cache->uc_name, entry, entry->ue_key,
+ atomic_read(&entry->ue_refcount),
+ entry->ue_flags, get_seconds(),
+ entry->ue_acquire_expire, entry->ue_expire);
GOTO(out, rc = -EINVAL);
}
}
UC_CACHE_SET_VALID(entry);
- CDEBUG(D_SEC, "create ucache entry %p(key "LPU64")\n",
- entry, entry->ue_key);
+ CDEBUG(D_SEC, "%s: create ucache entry %p(key "LPU64")\n",
+ cache->uc_name, entry, entry->ue_key);
out:
wake_up_all(&entry->ue_waitq);
write_unlock(&cache->uc_hashlock);
hash = cache->hash(cache, key);
LASSERT(hash < cache->uc_hashsize);
-
head = &cache->uc_hashtable[hash];
write_lock(&cache->uc_hashlock);
}
if (found) {
+ CWARN("%s: flush entry %p: key "LPU64", ref %d, fl %x, "
+ "cur %lu, ex %ld/%ld\n",
+ cache->uc_name, entry, entry->ue_key,
+ atomic_read(&entry->ue_refcount), entry->ue_flags,
+ get_seconds(), entry->ue_acquire_expire,
+ entry->ue_expire);
UC_CACHE_SET_EXPIRED(entry);
if (!atomic_read(&entry->ue_refcount))
free_entry(entry);
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
+#include <syslog.h>
#include <liblustre.h>
#include <linux/lustre_idl.h>
#include <portals/ptlctl.h>
#include <portals/types.h>
+static int g_testing = 0;
+
+#define log_msg(fmt, args...) \
+ { \
+ if (g_testing) \
+ printf(fmt, ## args); \
+ else \
+ syslog(LOG_ERR, fmt, ## args); \
+ }
+
int switch_user_identity(uid_t uid)
{
gid_t gid;
int i;
/* originally must be root */
- if (getuid() != 0 || geteuid() != 0)
+ if (getuid() != 0 || geteuid() != 0) {
+ log_msg("non-root: %u/%u\n", getuid(), geteuid());
return -EPERM;
+ }
/* nothing more is needed for root */
if (uid == 0)
*/
maxgroups = sysconf(_SC_NGROUPS_MAX);
groups = malloc(maxgroups * sizeof(gid_t));
- if (!groups)
+ if (!groups) {
+ log_msg("memory alloc failure\n");
return -ENOMEM;
+ }
pw = getpwuid(uid);
- if (!pw)
+ if (!pw) {
+ log_msg("no such uid %u\n", uid);
return -EPERM;
+ }
gid = pw->pw_gid;
endgrent();
if (setgroups(ngroups, groups) == -1) {
+ log_msg("set %d groups: %s\n", ngroups, strerror(errno));
free(groups);
return -EPERM;
}
free(groups);
if (setgid(gid) == -1) {
+ log_msg("setgid %u: %s\n", gid, strerror(errno));
return -EPERM;
}
if (setuid(uid) == -1) {
+ log_msg("setuid %u: %s\n", uid, strerror(errno));
return -EPERM;
}
}
if (chdir(lroot) < 0) {
+ log_msg("chdir to %s: %s\n", lroot, strerror(errno));
printf("MDS: can't change dir\n");
return;
}
int pipeout[2], pipeerr[2], pid;
int output_size, rd, childret;
- if (argc != 6)
+ if (argc != 6) {
+ log_msg("invalid argc %d\n", argc);
return -1;
+ }
+
+ /* XXX temp for debugging */
+ log_msg("enter: %s %s %s %s %s\n",
+ argv[1], argv[2], argv[3], argv[4], argv[5]);
- if (strcmp(argv[4], "get") && strcmp(argv[4], "set"))
+ if (strcmp(argv[4], "get") && strcmp(argv[4], "set")) {
+ log_msg("invalid arg 4: %s\n", argv[4]);
return -1;
+ }
dc_args.key = strtoull(argv[1], NULL, 16);
dc_args.res = output;
downcall:
dc_fd = open(dc_name, O_WRONLY);
- if (dc_fd != -1) {
- write(dc_fd, &dc_args, sizeof(dc_args));
+ if (dc_fd < 0) {
+ log_msg("can't open %s: %s\n", dc_name, strerror(errno));
+ } else {
+ int rc;
+
+ rc = write(dc_fd, &dc_args, sizeof(dc_args));
+ if (rc != sizeof(dc_args))
+ log_msg("write error: ret %d\n", rc);
+
close(dc_fd);
}
+ /* XXX temp for debugging */
+ log_msg("finished upcall\n");
return 0;
}