All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: Christoph Hellwig <hch@tuxera.com>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Anton Salikhmetov <alexo@tuxera.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	roman@ardistech.com, linux-kernel@vger.kernel.org,
	ldv-project@ispras.ru
Subject: [PATCH v2 2/2] hfsplus: Add error propagation for hfsplus_ext_write_extent_locked
Date: Wed,  6 Jul 2011 02:30:00 +0400	[thread overview]
Message-ID: <1309905000-28983-3-git-send-email-khoroshilov@ispras.ru> (raw)
In-Reply-To: <1309905000-28983-1-git-send-email-khoroshilov@ispras.ru>

Implement error propagation through the callers of
hfsplus_ext_write_extent_locked().

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 fs/hfsplus/extents.c    |   26 ++++++++++++++++++--------
 fs/hfsplus/hfsplus_fs.h |    2 +-
 fs/hfsplus/super.c      |    6 +++++-
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 59fa09f..9235c41 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -119,23 +119,31 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
 	set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
 }
 
-static void hfsplus_ext_write_extent_locked(struct inode *inode)
+static int hfsplus_ext_write_extent_locked(struct inode *inode)
 {
+	int res;
+
 	if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
 		struct hfs_find_data fd;
 
-		if (!hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd)) {
-			__hfsplus_ext_write_extent(inode, &fd);
-			hfs_find_exit(&fd);
-		}
+		res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
+		if (res)
+			return res;
+		__hfsplus_ext_write_extent(inode, &fd);
+		hfs_find_exit(&fd);
 	}
+	return 0;
 }
 
-void hfsplus_ext_write_extent(struct inode *inode)
+int hfsplus_ext_write_extent(struct inode *inode)
 {
+	int res;
+
 	mutex_lock(&HFSPLUS_I(inode)->extents_lock);
-	hfsplus_ext_write_extent_locked(inode);
+	res = hfsplus_ext_write_extent_locked(inode);
 	mutex_unlock(&HFSPLUS_I(inode)->extents_lock);
+
+	return res;
 }
 
 static inline int __hfsplus_ext_read_extent(struct hfs_find_data *fd,
@@ -474,7 +482,9 @@ out:
 
 insert_extent:
 	dprint(DBG_EXTENT, "insert new extent\n");
-	hfsplus_ext_write_extent_locked(inode);
+	res = hfsplus_ext_write_extent_locked(inode);
+	if (res)
+		goto out;
 
 	memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
 	hip->cached_extents[0].start_block = cpu_to_be32(start);
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index d685752..0bebf74 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -374,7 +374,7 @@ extern const struct file_operations hfsplus_dir_operations;
 
 /* extents.c */
 int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *);
-void hfsplus_ext_write_extent(struct inode *);
+int hfsplus_ext_write_extent(struct inode *);
 int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int);
 int hfsplus_free_fork(struct super_block *, u32,
 		struct hfsplus_fork_raw *, int);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 07a0502..0b41f4c 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -135,9 +135,13 @@ static int hfsplus_system_write_inode(struct inode *inode)
 static int hfsplus_write_inode(struct inode *inode,
 		struct writeback_control *wbc)
 {
+	int err;
+
 	dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
 
-	hfsplus_ext_write_extent(inode);
+	err = hfsplus_ext_write_extent(inode);
+	if (err)
+		return err;
 
 	if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
 	    inode->i_ino == HFSPLUS_ROOT_CNID)
-- 
1.7.4.1


  parent reply	other threads:[~2011-07-05 22:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 21:15 [PATCH 1/2] hfsplus: add error checking for hfs_find_init() Alexey Khoroshilov
2011-06-23 21:15 ` [PATCH 2/2] hfsplus: Fix double iput of the same inode in hfsplus_fill_super() Alexey Khoroshilov
2011-06-30 11:42   ` Christoph Hellwig
2011-06-30 11:42 ` [PATCH 1/2] hfsplus: add error checking for hfs_find_init() Christoph Hellwig
2011-07-05 22:29   ` [PATCH v2 0/2] " Alexey Khoroshilov
2011-07-05 22:29     ` [PATCH v2 1/2] " Alexey Khoroshilov
2011-07-05 22:30     ` Alexey Khoroshilov [this message]
2011-07-07 16:33     ` [PATCH v2 0/2] " Christoph Hellwig

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=1309905000-28983-3-git-send-email-khoroshilov@ispras.ru \
    --to=khoroshilov@ispras.ru \
    --cc=alexo@tuxera.com \
    --cc=hch@tuxera.com \
    --cc=ldv-project@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roman@ardistech.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.