diff options
author | Michael Kerrisk (man-pages) <mtk.manpages@gmail.com> | 2016-10-11 16:53:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-11 18:06:31 -0400 |
commit | 3734a13b96ebf039b293d8d37a934fd1bd9e03ab (patch) | |
tree | dac3b2be69a7f83d32643251efc51701acbae055 | |
parent | d37d41666408102bf0ac8e48d8efdce7b809e5f6 (diff) |
pipe: refactor argument for account_pipe_buffers()
This is a preparatory patch for following work. account_pipe_buffers()
performs accounting in the 'user_struct'. There is no need to pass a
pointer to a 'pipe_inode_info' struct (which is then dereferenced to
obtain a pointer to the 'user' field). Instead, pass a pointer directly
to the 'user_struct'. This change is needed in preparation for a
subsequent patch that the fixes the limit checking in alloc_pipe_info()
(and the resulting code is a little more logical).
Link: http://lkml.kernel.org/r/7277bf8c-a6fc-4a7d-659c-f5b145c981ab@gmail.com
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: <socketpair@gmail.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Jens Axboe <axboe@fb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/pipe.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -601,10 +601,10 @@ pipe_fasync(int fd, struct file *filp, int on) | |||
601 | return retval; | 601 | return retval; |
602 | } | 602 | } |
603 | 603 | ||
604 | static void account_pipe_buffers(struct pipe_inode_info *pipe, | 604 | static void account_pipe_buffers(struct user_struct *user, |
605 | unsigned long old, unsigned long new) | 605 | unsigned long old, unsigned long new) |
606 | { | 606 | { |
607 | atomic_long_add(new - old, &pipe->user->pipe_bufs); | 607 | atomic_long_add(new - old, &user->pipe_bufs); |
608 | } | 608 | } |
609 | 609 | ||
610 | static bool too_many_pipe_buffers_soft(struct user_struct *user) | 610 | static bool too_many_pipe_buffers_soft(struct user_struct *user) |
@@ -641,7 +641,7 @@ struct pipe_inode_info *alloc_pipe_info(void) | |||
641 | pipe->r_counter = pipe->w_counter = 1; | 641 | pipe->r_counter = pipe->w_counter = 1; |
642 | pipe->buffers = pipe_bufs; | 642 | pipe->buffers = pipe_bufs; |
643 | pipe->user = user; | 643 | pipe->user = user; |
644 | account_pipe_buffers(pipe, 0, pipe_bufs); | 644 | account_pipe_buffers(user, 0, pipe_bufs); |
645 | mutex_init(&pipe->mutex); | 645 | mutex_init(&pipe->mutex); |
646 | return pipe; | 646 | return pipe; |
647 | } | 647 | } |
@@ -656,7 +656,7 @@ void free_pipe_info(struct pipe_inode_info *pipe) | |||
656 | { | 656 | { |
657 | int i; | 657 | int i; |
658 | 658 | ||
659 | account_pipe_buffers(pipe, pipe->buffers, 0); | 659 | account_pipe_buffers(pipe->user, pipe->buffers, 0); |
660 | free_uid(pipe->user); | 660 | free_uid(pipe->user); |
661 | for (i = 0; i < pipe->buffers; i++) { | 661 | for (i = 0; i < pipe->buffers; i++) { |
662 | struct pipe_buffer *buf = pipe->bufs + i; | 662 | struct pipe_buffer *buf = pipe->bufs + i; |
@@ -1077,7 +1077,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) | |||
1077 | memcpy(bufs + head, pipe->bufs, tail * sizeof(struct pipe_buffer)); | 1077 | memcpy(bufs + head, pipe->bufs, tail * sizeof(struct pipe_buffer)); |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | account_pipe_buffers(pipe, pipe->buffers, nr_pages); | 1080 | account_pipe_buffers(pipe->user, pipe->buffers, nr_pages); |
1081 | pipe->curbuf = 0; | 1081 | pipe->curbuf = 0; |
1082 | kfree(pipe->bufs); | 1082 | kfree(pipe->bufs); |
1083 | pipe->bufs = bufs; | 1083 | pipe->bufs = bufs; |