From: Gerrit Huizenga Replace the target file interface with a writable members file. Signed-Off-By: Matt Helsley Signed-Off-By: Gerrit Huizenga Signed-off-by: Andrew Morton --- Documentation/ckrm/ckrm_basics | 12 ++++++++---- Documentation/ckrm/core_usage | 10 +++++----- fs/rcfs/magic.c | 41 +++++++++++++++++------------------------ fs/rcfs/socket_fs.c | 12 ------------ 4 files changed, 30 insertions(+), 45 deletions(-) diff -puN Documentation/ckrm/ckrm_basics~ckrm-replace-target-file-interface-with-a-writable-members-file Documentation/ckrm/ckrm_basics --- 25/Documentation/ckrm/ckrm_basics~ckrm-replace-target-file-interface-with-a-writable-members-file Wed Jul 13 14:44:42 2005 +++ 25-akpm/Documentation/ckrm/ckrm_basics Wed Jul 13 14:44:42 2005 @@ -33,12 +33,16 @@ shares: allows to change the shares of class stats: allows to see the statistics associated with each resources managed by the class -target: allows to assign a task to a class. If a CE is present, assigning - a task to a class through this interface will prevent CE from - reassigning the task to any class during reclassification. -members: allows to see which tasks has been assigned to a class +target: obsolete. functionality moved to 'members' file. +members: allows to assign a task to a class and to see which tasks has + been assigned to a class. + If a CE is present, assigning a task to a class through this + interface will prevent CE from reassigning the task to any class + during reclassification. config: allow to view and modify configuration information of different resources in a class. +reclassify: When CE is present, allows a task to be reclassified by CE. In + the absence of CE, this file provides no functionality. Resource allocations for a class is controlled by the parameters: diff -puN Documentation/ckrm/core_usage~ckrm-replace-target-file-interface-with-a-writable-members-file Documentation/ckrm/core_usage --- 25/Documentation/ckrm/core_usage~ckrm-replace-target-file-interface-with-a-writable-members-file Wed Jul 13 14:44:42 2005 +++ 25-akpm/Documentation/ckrm/core_usage Wed Jul 13 14:44:42 2005 @@ -9,7 +9,7 @@ Usage of CKRM without a classification e creates a socketclass named s1 The newly created class directory is automatically populated by magic files -shares, stats, members, target and config. +shares, stats, members, config and reclassify. 2. View default shares @@ -34,11 +34,11 @@ shares, stats, members, target and confi 4. Reclassify a task (listening socket) - write the pid of the process to the destination class' target file - # echo 1004 > /rcfs/taskclass/c1/target + write the pid of the process to the destination class' members file + # echo 1004 > /rcfs/taskclass/c1/members - write the "\" string to the destination class' target file - # echo "0.0.0.0\32770" > /rcfs/taskclass/c1/target + write the "\" string to the destination class' members file + # echo "0.0.0.0\32770" > /rcfs/taskclass/c1/members 5. Get a list of tasks (sockets) assigned to a taskclass (socketclass) diff -puN fs/rcfs/magic.c~ckrm-replace-target-file-interface-with-a-writable-members-file fs/rcfs/magic.c --- 25/fs/rcfs/magic.c~ckrm-replace-target-file-interface-with-a-writable-members-file Wed Jul 13 14:44:42 2005 +++ 25-akpm/fs/rcfs/magic.c Wed Jul 13 14:44:42 2005 @@ -209,29 +209,31 @@ out: } /* - * Shared function used by Target / Reclassify + * Shared function used by Members / Reclassify */ +#define MEMBERS_MAX_INPUT_SIZE MAX_INPUT_SIZE static ssize_t -target_reclassify_write(struct file *file, const char __user * buf, - size_t count, loff_t * ppos, int manual) +members_reclassify_write(struct file *file, const char __user * buf, + size_t count, loff_t * ppos, int manual) { struct rcfs_inode_info *ri = rcfs_get_inode_info(file->f_dentry->d_inode); char *optbuf; int rc = -EINVAL; struct ckrm_classtype *clstype; - if (count > MAX_INPUT_SIZE) + if (count > MEMBERS_MAX_INPUT_SIZE) return -EINVAL; if (!access_ok(VERIFY_READ, buf, count)) return -EFAULT; down(&(ri->vfs_inode.i_sem)); - optbuf = kmalloc(MAX_INPUT_SIZE, GFP_KERNEL); + optbuf = kmalloc(MEMBERS_MAX_INPUT_SIZE, GFP_KERNEL); __copy_from_user(optbuf, buf, count); mkvalidstr(optbuf); clstype = ri->core->classtype; if (clstype->forced_reclassify) - rc = (*clstype->forced_reclassify) (manual ? ri->core: NULL, optbuf); + rc = (*clstype->forced_reclassify) (manual ? ri->core : + NULL, optbuf); up(&(ri->vfs_inode.i_sem)); kfree(optbuf); return (!rc ? count : rc); @@ -239,23 +241,6 @@ target_reclassify_write(struct file *fil } /* - * Target - * - * pseudo file for manually reclassifying members to a class - */ - -static ssize_t -target_write(struct file *file, const char __user * buf, - size_t count, loff_t * ppos) -{ - return target_reclassify_write(file, buf, count, ppos, 1); -} - -struct file_operations target_fileops = { - .write = target_write, -}; - -/* * Reclassify * * pseudo file for reclassification of an object through CE @@ -265,7 +250,7 @@ static ssize_t reclassify_write(struct file *file, const char __user * buf, size_t count, loff_t * ppos) { - return target_reclassify_write(file, buf, count, ppos, 0); + return members_reclassify_write(file, buf, count, ppos, 0); } struct file_operations reclassify_fileops = { @@ -296,12 +281,20 @@ struct file_operations config_fileops = * * List members of a class */ +static ssize_t +members_write(struct file *file, const char __user * buf, + size_t count, loff_t * ppos) +{ + return members_reclassify_write(file,buf,count,ppos,1); +} + struct file_operations members_fileops = { .open = magic_open, .read = seq_read, .llseek = seq_lseek, .release = magic_close, + .write = members_write, }; /* diff -puN fs/rcfs/socket_fs.c~ckrm-replace-target-file-interface-with-a-writable-members-file fs/rcfs/socket_fs.c --- 25/fs/rcfs/socket_fs.c~ckrm-replace-target-file-interface-with-a-writable-members-file Wed Jul 13 14:44:42 2005 +++ 25-akpm/fs/rcfs/socket_fs.c Wed Jul 13 14:44:42 2005 @@ -65,12 +65,6 @@ struct rcfs_magf rcfs_sock_rootdesc[] = .i_fop = &members_fileops, }, { - .name = "target", - .mode = RCFS_DEFAULT_FILE_MODE, - .i_op = &my_iops, - .i_fop = &target_fileops, - }, - { .name = "reclassify", .mode = RCFS_DEFAULT_FILE_MODE, .i_op = &my_iops, @@ -103,12 +97,6 @@ struct rcfs_magf rcfs_sock_magf[] = { .i_op = &my_iops, .i_fop = &stats_fileops, }, - { - .name = "target", - .mode = RCFS_DEFAULT_FILE_MODE, - .i_op = &my_iops, - .i_fop = &target_fileops, - }, }; struct rcfs_magf sub_magf[] = { _