linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vyacheslav Dubeyko <slava@dubeyko.com>
To: Linux FS devel list <linux-fsdevel@vger.kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	ChristophHellwig <hch@infradead.org>,
	Hin-Tak Leung <htl10@users.sourceforge.net>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 10/14] hfsplus: implement functionality of journal log wrapping
Date: Thu, 26 Dec 2013 13:47:47 +0400	[thread overview]
Message-ID: <1388051267.4168.73.camel@slavad-ubuntu> (raw)

From: Vyacheslav Dubeyko <slava@dubeyko.com>
Subject: [PATCH 10/14] hfsplus: implement functionality of journal log wrapping

The journal log is a circular buffer. Thereby, journal log's content
can be splitted by journal end on two parts in some situations. When
reading or writing the journal buffer, the I/O operation must stop at
the end of the journal buffer and resume (wrap around) immediately
following the journal header.

This patch implements functionality of wrapping of journal log for such
situation. Namely, it means setting of "start" field of journal
header by journal header size value.

Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Christoph Hellwig <hch@infradead.org>
CC: Hin-Tak Leung <htl10@users.sourceforge.net>
---
 fs/hfsplus/journal.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/fs/hfsplus/journal.c b/fs/hfsplus/journal.c
index c1fefc2..fc88d2b 100644
--- a/fs/hfsplus/journal.c
+++ b/fs/hfsplus/journal.c
@@ -290,6 +290,36 @@ static inline bool need_to_wrap_journal(struct hfsplus_journal_header *jh,
 	return (cur_off + req_size) > JOURNAL_SIZE(jh);
 }
 
+static inline void __hfsplus_wrap_journal(struct super_block *sb)
+{
+	struct hfsplus_journal *jnl = HFSPLUS_SB(sb)->jnl;
+
+	jnl->jh->start = jnl->jh->jhdr_size;
+}
+
+/* Return rest bytes of binfo or blhdr from the journal begin */
+static inline u32 hfsplus_wrap_journal(struct super_block *sb,
+					u64 cur_off, u32 req_size)
+{
+	struct hfsplus_journal *jnl = HFSPLUS_SB(sb)->jnl;
+	struct hfsplus_journal_header *jh = jnl->jh;
+	u32 used_bytes;
+	u32 rest_bytes;
+
+	hfs_dbg(JOURNAL, "cur_off %llu, req_size %u, JOURNAL_SIZE(jh) %llu\n",
+		cur_off, req_size, JOURNAL_SIZE(jh));
+
+	BUG_ON(cur_off > JOURNAL_SIZE(jh));
+	BUG_ON((cur_off + req_size) < JOURNAL_SIZE(jh));
+
+	used_bytes = JOURNAL_SIZE(jh) - cur_off;
+	rest_bytes = req_size - used_bytes;
+
+	__hfsplus_wrap_journal(sb);
+
+	return rest_bytes;
+}
+
 static void hfsplus_deinit_block_list_desc(struct hfsplus_blist_desc *desc);
 
 static int hfsplus_init_block_list_desc(struct super_block *sb,
-- 
1.7.9.5




                 reply	other threads:[~2013-12-26  9:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1388051267.4168.73.camel@slavad-ubuntu \
    --to=slava@dubeyko.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=htl10@users.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).