diff options
-rw-r--r-- | include/linux/cgroup.h | 4 | ||||
-rw-r--r-- | kernel/cgroup.c | 21 |
2 files changed, 14 insertions, 11 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index e78377a91a74..cc59d3a21d87 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -21,11 +21,13 @@ | |||
21 | struct cgroupfs_root; | 21 | struct cgroupfs_root; |
22 | struct cgroup_subsys; | 22 | struct cgroup_subsys; |
23 | struct inode; | 23 | struct inode; |
24 | struct cgroup; | ||
24 | 25 | ||
25 | extern int cgroup_init_early(void); | 26 | extern int cgroup_init_early(void); |
26 | extern int cgroup_init(void); | 27 | extern int cgroup_init(void); |
27 | extern void cgroup_init_smp(void); | 28 | extern void cgroup_init_smp(void); |
28 | extern void cgroup_lock(void); | 29 | extern void cgroup_lock(void); |
30 | extern bool cgroup_lock_live_group(struct cgroup *cgrp); | ||
29 | extern void cgroup_unlock(void); | 31 | extern void cgroup_unlock(void); |
30 | extern void cgroup_fork(struct task_struct *p); | 32 | extern void cgroup_fork(struct task_struct *p); |
31 | extern void cgroup_fork_callbacks(struct task_struct *p); | 33 | extern void cgroup_fork_callbacks(struct task_struct *p); |
@@ -295,8 +297,6 @@ int cgroup_add_files(struct cgroup *cgrp, | |||
295 | 297 | ||
296 | int cgroup_is_removed(const struct cgroup *cgrp); | 298 | int cgroup_is_removed(const struct cgroup *cgrp); |
297 | 299 | ||
298 | int cgroup_lock_live_group(struct cgroup *cgrp); | ||
299 | |||
300 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); | 300 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen); |
301 | 301 | ||
302 | int cgroup_task_count(const struct cgroup *cgrp); | 302 | int cgroup_task_count(const struct cgroup *cgrp); |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 0120b5d67a73..a14122ecaa5e 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1329,10 +1329,10 @@ enum cgroup_filetype { | |||
1329 | * cgroup_lock_live_group - take cgroup_mutex and check that cgrp is alive. | 1329 | * cgroup_lock_live_group - take cgroup_mutex and check that cgrp is alive. |
1330 | * @cgrp: the cgroup to be checked for liveness | 1330 | * @cgrp: the cgroup to be checked for liveness |
1331 | * | 1331 | * |
1332 | * Returns true (with lock held) on success, or false (with no lock | 1332 | * On success, returns true; the lock should be later released with |
1333 | * held) on failure. | 1333 | * cgroup_unlock(). On failure returns false with no lock held. |
1334 | */ | 1334 | */ |
1335 | int cgroup_lock_live_group(struct cgroup *cgrp) | 1335 | bool cgroup_lock_live_group(struct cgroup *cgrp) |
1336 | { | 1336 | { |
1337 | mutex_lock(&cgroup_mutex); | 1337 | mutex_lock(&cgroup_mutex); |
1338 | if (cgroup_is_removed(cgrp)) { | 1338 | if (cgroup_is_removed(cgrp)) { |
@@ -1349,7 +1349,7 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft, | |||
1349 | if (!cgroup_lock_live_group(cgrp)) | 1349 | if (!cgroup_lock_live_group(cgrp)) |
1350 | return -ENODEV; | 1350 | return -ENODEV; |
1351 | strcpy(cgrp->root->release_agent_path, buffer); | 1351 | strcpy(cgrp->root->release_agent_path, buffer); |
1352 | mutex_unlock(&cgroup_mutex); | 1352 | cgroup_unlock(); |
1353 | return 0; | 1353 | return 0; |
1354 | } | 1354 | } |
1355 | 1355 | ||
@@ -1360,16 +1360,19 @@ static int cgroup_release_agent_show(struct cgroup *cgrp, struct cftype *cft, | |||
1360 | return -ENODEV; | 1360 | return -ENODEV; |
1361 | seq_puts(seq, cgrp->root->release_agent_path); | 1361 | seq_puts(seq, cgrp->root->release_agent_path); |
1362 | seq_putc(seq, '\n'); | 1362 | seq_putc(seq, '\n'); |
1363 | mutex_unlock(&cgroup_mutex); | 1363 | cgroup_unlock(); |
1364 | return 0; | 1364 | return 0; |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | /* A buffer size big enough for numbers or short strings */ | ||
1368 | #define CGROUP_LOCAL_BUFFER_SIZE 64 | ||
1369 | |||
1367 | static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft, | 1370 | static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft, |
1368 | struct file *file, | 1371 | struct file *file, |
1369 | const char __user *userbuf, | 1372 | const char __user *userbuf, |
1370 | size_t nbytes, loff_t *unused_ppos) | 1373 | size_t nbytes, loff_t *unused_ppos) |
1371 | { | 1374 | { |
1372 | char buffer[64]; | 1375 | char buffer[CGROUP_LOCAL_BUFFER_SIZE]; |
1373 | int retval = 0; | 1376 | int retval = 0; |
1374 | char *end; | 1377 | char *end; |
1375 | 1378 | ||
@@ -1403,7 +1406,7 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft, | |||
1403 | const char __user *userbuf, | 1406 | const char __user *userbuf, |
1404 | size_t nbytes, loff_t *unused_ppos) | 1407 | size_t nbytes, loff_t *unused_ppos) |
1405 | { | 1408 | { |
1406 | char local_buffer[64]; | 1409 | char local_buffer[CGROUP_LOCAL_BUFFER_SIZE]; |
1407 | int retval = 0; | 1410 | int retval = 0; |
1408 | size_t max_bytes = cft->max_write_len; | 1411 | size_t max_bytes = cft->max_write_len; |
1409 | char *buffer = local_buffer; | 1412 | char *buffer = local_buffer; |
@@ -1518,7 +1521,7 @@ static ssize_t cgroup_read_u64(struct cgroup *cgrp, struct cftype *cft, | |||
1518 | char __user *buf, size_t nbytes, | 1521 | char __user *buf, size_t nbytes, |
1519 | loff_t *ppos) | 1522 | loff_t *ppos) |
1520 | { | 1523 | { |
1521 | char tmp[64]; | 1524 | char tmp[CGROUP_LOCAL_BUFFER_SIZE]; |
1522 | u64 val = cft->read_u64(cgrp, cft); | 1525 | u64 val = cft->read_u64(cgrp, cft); |
1523 | int len = sprintf(tmp, "%llu\n", (unsigned long long) val); | 1526 | int len = sprintf(tmp, "%llu\n", (unsigned long long) val); |
1524 | 1527 | ||
@@ -1530,7 +1533,7 @@ static ssize_t cgroup_read_s64(struct cgroup *cgrp, struct cftype *cft, | |||
1530 | char __user *buf, size_t nbytes, | 1533 | char __user *buf, size_t nbytes, |
1531 | loff_t *ppos) | 1534 | loff_t *ppos) |
1532 | { | 1535 | { |
1533 | char tmp[64]; | 1536 | char tmp[CGROUP_LOCAL_BUFFER_SIZE]; |
1534 | s64 val = cft->read_s64(cgrp, cft); | 1537 | s64 val = cft->read_s64(cgrp, cft); |
1535 | int len = sprintf(tmp, "%lld\n", (long long) val); | 1538 | int len = sprintf(tmp, "%lld\n", (long long) val); |
1536 | 1539 | ||