From: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
To: users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org
Cc: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
Subject: [PATCH 2/3] nilfs2: clean up nilfs_write_super
Date: Wed, 22 Jul 2009 17:45:22 +0900 [thread overview]
Message-ID: <1248252323-22959-3-git-send-email-jir@unicus.jp> (raw)
In-Reply-To: <1248252323-22959-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
Separate conditions that check if syncing super block and alternative
super block are required as inline functions to reuse the conditions.
Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
fs/nilfs2/super.c | 11 +++--------
fs/nilfs2/the_nilfs.h | 14 ++++++++++++++
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 13614d8..02f7a76 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -365,17 +365,12 @@ static void nilfs_write_super(struct super_block *sb)
down_write(&nilfs->ns_sem);
if (!(sb->s_flags & MS_RDONLY)) {
- struct nilfs_super_block **sbp = nilfs->ns_sbp;
- u64 t = get_seconds();
- int dupsb;
-
- if (!nilfs_discontinued(nilfs) && t >= nilfs->ns_sbwtime[0] &&
- t < nilfs->ns_sbwtime[0] + NILFS_SB_FREQ) {
+ if (!nilfs_discontinued(nilfs) &&
+ !nilfs_sb_need_update(nilfs)) {
up_write(&nilfs->ns_sem);
return;
}
- dupsb = sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
- nilfs_commit_super(sbi, dupsb);
+ nilfs_commit_super(sbi, nilfs_altsb_need_update(nilfs));
}
sb->s_dirt = 0;
up_write(&nilfs->ns_sem);
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index e8adbff..37f9f35 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -202,6 +202,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued)
#define NILFS_SB_FREQ 10
#define NILFS_ALTSB_FREQ 60 /* spare superblock */
+static inline int nilfs_sb_need_update(struct the_nilfs *nilfs)
+{
+ u64 t = get_seconds();
+ return t < nilfs->ns_sbwtime[0] ||
+ t > nilfs->ns_sbwtime[0] + NILFS_SB_FREQ;
+}
+
+static inline int nilfs_altsb_need_update(struct the_nilfs *nilfs)
+{
+ u64 t = get_seconds();
+ struct nilfs_super_block **sbp = nilfs->ns_sbp;
+ return sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
+}
+
void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
struct the_nilfs *find_or_create_nilfs(struct block_device *);
void put_nilfs(struct the_nilfs *);
--
1.5.6.5
next prev parent reply other threads:[~2009-07-22 8:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-22 8:45 [PATCH 0/3] v3: write_super clean up Jiro SEKIBA
[not found] ` <1248252323-22959-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2009-07-22 8:45 ` [PATCH 1/3] nilfs2: fix disorder of nilfs_write_super in nilfs_sync_fs Jiro SEKIBA
2009-07-22 8:45 ` Jiro SEKIBA [this message]
2009-07-22 8:45 ` [PATCH 3/3] nilfs2: stop using periodic write_super callback Jiro SEKIBA
2009-07-22 17:06 ` [PATCH 0/3] v3: write_super clean up Ryusuke Konishi
-- strict thread matches above, loose matches on Subject: below --
2009-07-19 5:26 [PATCH 0/3] v2: " Jiro SEKIBA
[not found] ` <1247981182-14831-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2009-07-19 5:26 ` [PATCH 2/3] nilfs2: clean up nilfs_write_super Jiro SEKIBA
2009-07-17 9:12 [PATCH 0/3] write_super clean up Jiro SEKIBA
[not found] ` <1247821968-31232-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2009-07-17 9:12 ` [PATCH 2/3] nilfs2: clean up nilfs_write_super Jiro SEKIBA
[not found] ` <1247821968-31232-3-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2009-07-17 16:24 ` Ryusuke Konishi
[not found] ` <20090718.012414.19435380.ryusuke-sG5X7nlA6pw@public.gmane.org>
2009-07-18 7:00 ` Jiro SEKIBA
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1248252323-22959-3-git-send-email-jir@unicus.jp \
--to=jir-hfpbi5wx9j54eiagz67ipq@public.gmane.org \
--cc=users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox