From f3cd63639b324ba30805cdcc24d0955cea4c666b Mon Sep 17 00:00:00 2001 From: fanyong Date: Tue, 31 Oct 2006 08:50:45 +0000 Subject: [PATCH] Support flush specific user identity info. --- lustre/mdt/mdt_identity.c | 4 ++-- lustre/mdt/mdt_internal.h | 2 +- lustre/mdt/mdt_lproc.c | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lustre/mdt/mdt_identity.c b/lustre/mdt/mdt_identity.c index 399b0b2..0db1208 100644 --- a/lustre/mdt/mdt_identity.c +++ b/lustre/mdt/mdt_identity.c @@ -199,9 +199,9 @@ struct upcall_cache_ops mdt_identity_upcall_cache_ops = { .parse_downcall = mdt_identity_parse_downcall, }; -void mdt_flush_identity(struct upcall_cache *cache, __u32 uid) +void mdt_flush_identity(struct upcall_cache *cache, int uid) { - if (uid == -1) + if (uid < 0) upcall_cache_flush_idle(cache); else upcall_cache_flush_one(cache, (__u64)uid, NULL); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 8c2baca..8ef055a 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -593,7 +593,7 @@ struct mdt_identity *mdt_identity_get(struct upcall_cache *, __u32); void mdt_identity_put(struct upcall_cache *, struct mdt_identity *); -void mdt_flush_identity(struct upcall_cache *, __u32); +void mdt_flush_identity(struct upcall_cache *, int); __u32 mdt_identity_get_setxid_perm(struct mdt_identity *, __u32, lnet_nid_t); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 941fd80..c9aeb80 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -154,8 +154,21 @@ static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, { struct obd_device *obd = data; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + char tmp[8]; + int uid; - upcall_cache_flush_idle(mdt->mdt_identity_cache); + memset(tmp, 0, 8); + if (copy_from_user(tmp, buffer, (count > 7) ? 7 : count)) { + CERROR("%s: bad data\n", obd->obd_name); + return -EFAULT; + } + + if (sscanf(tmp, "%d", &uid) != 1) { + CERROR("%s: invalid uid\n", obd->obd_name); + return -EFAULT; + } + + mdt_flush_identity(mdt->mdt_identity_cache, uid); return count; } @@ -400,7 +413,7 @@ static int lprocfs_wr_rootsquash_uid(struct file *file, const char *buffer, if (!mdt->mdt_rootsquash_info) OBD_ALLOC_PTR(mdt->mdt_rootsquash_info); if (!mdt->mdt_rootsquash_info) - RETURN(-ENOMEM); + return -ENOMEM; mdt->mdt_rootsquash_info->rsi_uid = val; return count; @@ -432,7 +445,7 @@ static int lprocfs_wr_rootsquash_gid(struct file *file, const char *buffer, if (!mdt->mdt_rootsquash_info) OBD_ALLOC_PTR(mdt->mdt_rootsquash_info); if (!mdt->mdt_rootsquash_info) - RETURN(-ENOMEM); + return -ENOMEM; mdt->mdt_rootsquash_info->rsi_gid = val; return count; @@ -516,7 +529,7 @@ static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer, if (!mdt->mdt_rootsquash_info) OBD_ALLOC_PTR(mdt->mdt_rootsquash_info); if (!mdt->mdt_rootsquash_info) - RETURN(-ENOMEM); + return -ENOMEM; remove_newline(skips); do_process_nosquash_nids(mdt, skips); -- 1.8.3.1