[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190513181516.11131-1-sterchelen@gmail.com>
Date: Mon, 13 May 2019 20:15:15 +0200
From: sterchelen <sterchelen@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: sterchelen <sterchelen@...il.com>,
Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org
Subject: [PATCH] kernel: Fix acct coding style
Improve readability by applying coding style
Signed-off-by: Nicolas Sterchele <sterchelen@...il.com>
---
kernel/acct.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/kernel/acct.c b/kernel/acct.c
index 81f9831a7859..7369960a9555 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -111,6 +111,7 @@ static int check_free_space(struct bsd_acct_struct *acct)
if (acct->active) {
u64 suspend = sbuf.f_blocks * SUSPEND;
+
do_div(suspend, 100);
if (sbuf.f_bavail <= suspend) {
acct->active = 0;
@@ -118,6 +119,7 @@ static int check_free_space(struct bsd_acct_struct *acct)
}
} else {
u64 resume = sbuf.f_blocks * RESUME;
+
do_div(resume, 100);
if (sbuf.f_bavail >= resume) {
acct->active = 1;
@@ -170,6 +172,7 @@ static struct bsd_acct_struct *acct_get(struct pid_namespace *ns)
static void acct_pin_kill(struct fs_pin *pin)
{
struct bsd_acct_struct *acct = to_acct(pin);
+
mutex_lock(&acct->lock);
do_acct_process(acct);
schedule_work(&acct->work);
@@ -182,8 +185,12 @@ static void acct_pin_kill(struct fs_pin *pin)
static void close_work(struct work_struct *work)
{
- struct bsd_acct_struct *acct = container_of(work, struct bsd_acct_struct, work);
+ struct bsd_acct_struct *acct = container_of(
+ work,
+ struct bsd_acct_struct,
+ work);
struct file *file = acct->file;
+
if (file->f_op->flush)
file->f_op->flush(file, NULL);
__fput_sync(file);
@@ -389,8 +396,8 @@ static comp2_t encode_comp2_t(u64 value)
*/
static u32 encode_float(u64 value)
{
- unsigned exp = 190;
- unsigned u;
+ unsigned int exp = 190;
+ unsigned int u;
if (value == 0)
return 0;
@@ -449,7 +456,7 @@ static void fill_ac(acct_t *ac)
#endif
do_div(elapsed, AHZ);
ac->ac_btime = get_seconds() - elapsed;
-#if ACCT_VERSION==2
+#if ACCT_VERSION == 2
ac->ac_ahz = AHZ;
#endif
@@ -505,8 +512,9 @@ static void do_acct_process(struct bsd_acct_struct *acct)
ac.ac_pid = task_tgid_nr_ns(current, ns);
rcu_read_lock();
- ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent),
- ns);
+ ac.ac_ppid = task_tgid_nr_ns(
+ rcu_dereference(current->real_parent),
+ ns);
rcu_read_unlock();
}
#endif
@@ -517,6 +525,7 @@ static void do_acct_process(struct bsd_acct_struct *acct)
if (file_start_write_trylock(file)) {
/* it's been opened O_APPEND, so position is irrelevant */
loff_t pos = 0;
+
__kernel_write(file, &ac, sizeof(acct_t), &pos);
file_end_write(file);
}
@@ -575,6 +584,7 @@ static void slow_acct_process(struct pid_namespace *ns)
{
for ( ; ns; ns = ns->parent) {
struct bsd_acct_struct *acct = acct_get(ns);
+
if (acct) {
do_acct_process(acct);
mutex_unlock(&acct->lock);
--
2.21.0
Powered by blists - more mailing lists