Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1286076 > unrolled thread
| Started by | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| First post | 2015-12-08 00:00 +0100 |
| Last post | 2015-12-09 07:10 +0100 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/3] f2fs: enhance the bit operation for SSR Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
[PATCH 3/3] f2fs: use lock_buffer when changing superblock Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
RE: [f2fs-dev] [PATCH 3/3] f2fs: use lock_buffer when changing superblock Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:20 +0100
Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: use lock_buffer when changing superblock Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-09 19:00 +0100
[PATCH 2/3] f2fs: refactor f2fs_commit_super Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-08 00:00 +0100
RE: [f2fs-dev] [PATCH 2/3] f2fs: refactor f2fs_commit_super Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:10 +0100
RE: [f2fs-dev] [PATCH 1/3] f2fs: enhance the bit operation for SSR Chao Yu <chao2.yu@samsung.com> - 2015-12-09 07:10 +0100
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-08 00:00 +0100 |
| Subject | [PATCH 1/3] f2fs: enhance the bit operation for SSR |
| Message-ID | <qDcVc-2rG-13@gated-at.bofh.it> |
This patch enhances the existing bit operation when f2fs allocates SSR
blocks.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/segment.c | 50 ++++++++++++++++++++------------------------------
1 file changed, 20 insertions(+), 30 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 74c4748..5fa519f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -132,47 +132,37 @@ static unsigned long __find_rev_next_zero_bit(const unsigned long *addr,
unsigned long size, unsigned long offset)
{
const unsigned long *p = addr + BIT_WORD(offset);
- unsigned long result = offset & ~(BITS_PER_LONG - 1);
+ unsigned long result = size;
unsigned long tmp;
if (offset >= size)
return size;
- size -= result;
+ size -= (offset & ~(BITS_PER_LONG - 1));
offset %= BITS_PER_LONG;
- if (!offset)
- goto aligned;
-
- tmp = __reverse_ulong((unsigned char *)p);
- tmp |= ~((~0UL << offset) >> offset);
-
- if (size < BITS_PER_LONG)
- goto found_first;
- if (tmp != ~0UL)
- goto found_middle;
-
- size -= BITS_PER_LONG;
- result += BITS_PER_LONG;
- p++;
-aligned:
- while (size & ~(BITS_PER_LONG - 1)) {
+
+ while (1) {
+ if (*p == ~0UL)
+ goto pass;
+
tmp = __reverse_ulong((unsigned char *)p);
+
+ if (offset)
+ tmp |= ~0UL << (BITS_PER_LONG - offset);
+ if (size < BITS_PER_LONG)
+ tmp |= ~0UL >> size;
if (tmp != ~0UL)
- goto found_middle;
- result += BITS_PER_LONG;
+ goto found;
+pass:
+ if (size <= BITS_PER_LONG)
+ break;
size -= BITS_PER_LONG;
+ offset = 0;
p++;
}
- if (!size)
- return result;
-
- tmp = __reverse_ulong((unsigned char *)p);
-found_first:
- tmp |= ~(~0UL << (BITS_PER_LONG - size));
- if (tmp == ~0UL) /* Are any bits zero? */
- return result + size; /* Nope. */
-found_middle:
- return result + __reverse_ffz(tmp);
+ return result;
+found:
+ return result - size + __reverse_ffz(tmp);
}
void register_inmem_page(struct inode *inode, struct page *page)
--
2.4.9 (Apple Git-60)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-08 00:00 +0100 |
| Subject | [PATCH 3/3] f2fs: use lock_buffer when changing superblock |
| Message-ID | <qDcVc-2rG-15@gated-at.bofh.it> |
| In reply to | #1286076 |
When modifying sb contents, we need to use lock its buffer. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> --- fs/f2fs/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a018ed3..a16dfe9 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1591,7 +1591,9 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg) return err; /* update superblock with uuid */ + lock_buffer(sbi->raw_super_buf); generate_random_uuid(sbi->raw_super->encrypt_pw_salt); + unlock_buffer(sbi->raw_super_buf); err = f2fs_commit_super(sbi, false); -- 2.4.9 (Apple Git-60) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Chao Yu <chao2.yu@samsung.com> |
|---|---|
| Date | 2015-12-09 07:20 +0100 |
| Subject | RE: [f2fs-dev] [PATCH 3/3] f2fs: use lock_buffer when changing superblock |
| Message-ID | <qDGgy-4B7-11@gated-at.bofh.it> |
| In reply to | #1286077 |
Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Tuesday, December 08, 2015 6:53 AM > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Cc: Jaegeuk Kim > Subject: [f2fs-dev] [PATCH 3/3] f2fs: use lock_buffer when changing superblock > > When modifying sb contents, we need to use lock its buffer. How about applying the rule to _undo_ flow after f2fs_commit_super failed? Thanks, > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > --- > fs/f2fs/file.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index a018ed3..a16dfe9 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -1591,7 +1591,9 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned > long arg) > return err; > > /* update superblock with uuid */ > + lock_buffer(sbi->raw_super_buf); > generate_random_uuid(sbi->raw_super->encrypt_pw_salt); > + unlock_buffer(sbi->raw_super_buf); > > err = f2fs_commit_super(sbi, false); > > -- > 2.4.9 (Apple Git-60) > > > ------------------------------------------------------------------------------ > Go from Idea to Many App Stores Faster with Intel(R) XDK > Give your users amazing mobile app experiences with Intel(R) XDK. > Use one codebase in this all-in-one HTML5 development environment. > Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. > http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-09 19:00 +0100 |
| Subject | Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: use lock_buffer when changing superblock |
| Message-ID | <qDRbY-351-13@gated-at.bofh.it> |
| In reply to | #1287137 |
Agreed.
Change log from v1:
o apply for _undo_ flow as well
From ea212a4a7a432e0ecd0f0f53971b70172b3e7f96 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Mon, 7 Dec 2015 10:18:54 -0800
Subject: [PATCH] f2fs: use lock_buffer when changing superblock
When modifying sb contents, we need to use lock its buffer.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/file.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index a018ed3..294e715 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1591,14 +1591,18 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
return err;
/* update superblock with uuid */
+ lock_buffer(sbi->raw_super_buf);
generate_random_uuid(sbi->raw_super->encrypt_pw_salt);
+ unlock_buffer(sbi->raw_super_buf);
err = f2fs_commit_super(sbi, false);
mnt_drop_write_file(filp);
if (err) {
/* undo new data */
+ lock_buffer(sbi->raw_super_buf);
memset(sbi->raw_super->encrypt_pw_salt, 0, 16);
+ unlock_buffer(sbi->raw_super_buf);
return err;
}
got_it:
--
2.4.9 (Apple Git-60)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-08 00:00 +0100 |
| Subject | [PATCH 2/3] f2fs: refactor f2fs_commit_super |
| Message-ID | <qDcVc-2rG-11@gated-at.bofh.it> |
| In reply to | #1286076 |
Previously, f2fs_commit_super hacks the bh->blocknr to write the broken
alternate superblock.
Instead of it, we should use the correct logic to retrieve its buffer head
with locking it appropriately.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/super.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index bd7e9c6..dbf16ad 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1099,27 +1099,35 @@ out:
int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
{
struct buffer_head *sbh = sbi->raw_super_buf;
- sector_t block = sbh->b_blocknr;
+ struct buffer_head *bh;
int err;
/* write back-up superblock first */
- sbh->b_blocknr = block ? 0 : 1;
- mark_buffer_dirty(sbh);
- err = sync_dirty_buffer(sbh);
+ bh = sb_getblk(sbi->sb, sbh->b_blocknr ? 0 : 1);
+ if (!bh)
+ return -EIO;
- sbh->b_blocknr = block;
+ lock_buffer(bh);
+ memcpy(bh->b_data, sbh->b_data, sbh->b_size);
+ WARN_ON(sbh->b_size != F2FS_BLKSIZE);
+ set_buffer_uptodate(bh);
+ set_buffer_dirty(bh);
+ unlock_buffer(bh);
+
+ /* it's rare case, we can do fua all the time */
+ err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
+ brelse(bh);
/* if we are in recovery path, skip writing valid superblock */
if (recover || err)
- goto out;
+ return err;
/* write current valid superblock */
- mark_buffer_dirty(sbh);
- err = sync_dirty_buffer(sbh);
-out:
- clear_buffer_write_io_error(sbh);
- set_buffer_uptodate(sbh);
- return err;
+ lock_buffer(sbh);
+ set_buffer_dirty(sbh);
+ unlock_buffer(sbh);
+
+ return __sync_dirty_buffer(sbh, WRITE_FLUSH_FUA);
}
static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
--
2.4.9 (Apple Git-60)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Chao Yu <chao2.yu@samsung.com> |
|---|---|
| Date | 2015-12-09 07:10 +0100 |
| Subject | RE: [f2fs-dev] [PATCH 2/3] f2fs: refactor f2fs_commit_super |
| Message-ID | <qDG6R-4xI-1@gated-at.bofh.it> |
| In reply to | #1286079 |
> -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Tuesday, December 08, 2015 6:53 AM > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Cc: Jaegeuk Kim > Subject: [f2fs-dev] [PATCH 2/3] f2fs: refactor f2fs_commit_super > > Previously, f2fs_commit_super hacks the bh->blocknr to write the broken > alternate superblock. > Instead of it, we should use the correct logic to retrieve its buffer head > with locking it appropriately. > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Reviewed-by: Chao Yu <chao2.yu@samsung.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Chao Yu <chao2.yu@samsung.com> |
|---|---|
| Date | 2015-12-09 07:10 +0100 |
| Subject | RE: [f2fs-dev] [PATCH 1/3] f2fs: enhance the bit operation for SSR |
| Message-ID | <qDG6R-4xI-3@gated-at.bofh.it> |
| In reply to | #1286076 |
> -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Tuesday, December 08, 2015 6:53 AM > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Cc: Jaegeuk Kim > Subject: [f2fs-dev] [PATCH 1/3] f2fs: enhance the bit operation for SSR > > This patch enhances the existing bit operation when f2fs allocates SSR > blocks. > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Reviewed-by: Chao Yu <chao2.yu@samsung.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web