[PATCH] btrfs: kick off the useless parameter
If there is no future development plan, this parameter for btrfs_root should be removed. --- Signed-off-by: Liu Wenyi --- fs/btrfs/compression.c |3 +-- fs/btrfs/disk-io.c |6 +++--- fs/btrfs/disk-io.h |2 +- fs/btrfs/file-item.c|3 +-- fs/btrfs/free-space-cache.c |6 +++--- fs/btrfs/inode.c|5 ++--- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 41d1d7c..499d8a4 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -105,7 +105,6 @@ static int check_compressed_csum(struct inode *inode, u64 disk_start) { int ret; - struct btrfs_root *root = BTRFS_I(inode)->root; struct page *page; unsigned long i; char *kaddr; @@ -120,7 +119,7 @@ static int check_compressed_csum(struct inode *inode, csum = ~(u32)0; kaddr = kmap_atomic(page, KM_USER0); - csum = btrfs_csum_data(root, kaddr, csum, PAGE_CACHE_SIZE); + csum = btrfs_csum_data(kaddr, csum, PAGE_CACHE_SIZE); btrfs_csum_final(csum, (char *)&csum); kunmap_atomic(kaddr, KM_USER0); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index fe5aec9..77fee13 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -192,7 +192,7 @@ out: return em; } -u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len) +u32 btrfs_csum_data(char *data, u32 seed, size_t len) { return crc32c(seed, data, len); } @@ -231,7 +231,7 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, if (err) return 1; cur_len = min(len, map_len - (offset - map_start)); - crc = btrfs_csum_data(root, kaddr + offset - map_start, + crc = btrfs_csum_data(kaddr + offset - map_start, crc, cur_len); len -= cur_len; offset += cur_len; @@ -2359,7 +2359,7 @@ static int write_dev_supers(struct btrfs_device *device, btrfs_set_super_bytenr(sb, bytenr); crc = ~(u32)0; - crc = btrfs_csum_data(NULL, (char *)sb + + crc = btrfs_csum_data((char *)sb + BTRFS_CSUM_SIZE, crc, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 07b20dc..9bef3e0 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -79,7 +79,7 @@ int btrfs_set_buffer_uptodate(struct extent_buffer *buf); int wait_on_tree_block_writeback(struct btrfs_root *root, struct extent_buffer *buf); int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid); -u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len); +u32 btrfs_csum_data(char *data, u32 seed, size_t len); void btrfs_csum_final(u32 crc, char *result); int btrfs_open_device(struct btrfs_device *dev); int btrfs_verify_block_csum(struct btrfs_root *root, diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index a6a9d4e..611a1be 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -432,8 +432,7 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, data = kmap_atomic(bvec->bv_page, KM_USER0); sector_sum->sum = ~(u32)0; - sector_sum->sum = btrfs_csum_data(root, - data + bvec->bv_offset, + sector_sum->sum = btrfs_csum_data(data + bvec->bv_offset, sector_sum->sum, bvec->bv_len); kunmap_atomic(data, KM_USER0); diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 63731a1..64ffb39 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -378,7 +378,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, /* First lets check our crc before we do anything fun */ cur_crc = ~(u32)0; - cur_crc = btrfs_csum_data(root, addr + start_offset, cur_crc, + cur_crc = btrfs_csum_data(addr + start_offset, cur_crc, PAGE_CACHE_SIZE - start_offset); btrfs_csum_final(cur_crc, (char *)&cur_crc); if (cur_crc != *crc) { @@ -710,7 +710,7 @@ int btrfs_write_out_cache(struct btrfs_root *root, entry++; } *crc = ~(u32)0; - *crc = btrfs_csum_data(root, addr + start_offset, *crc, + *crc = btrfs_csum_data(addr + start_offset, *crc,
Re: Raid1 resync
Hi Libor: Maybe, you can attach your oops at first. --- Best Regards, Liu Wenyi 2011/3/11 Libor Klepáč > > Hi, > before my ssd crashed, my /home partion was sitting on md raid1 consisting of > partition on disk and iScsi LUN in network, it was created with bitmaps and > iscsi lun was set writemostly. > So when i came to work, i fired up iscsi, added lun to raid and partial resync > went ahead. > Before leaving work, i failed iscsci disk and kicked it from raid. > I would like to use something like this with btrfs, without mdraid below it. > > Is it somehow posible? > 1) I can't go below 2 devices. > 2) Does btrfs support resync only of changed blocks like mdraid with bitmaps? > > Thanks > Libor -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 3/4] Btrfs add readonly support for error handle
Hi Xie Miao: I cannot understand the btrfs_decode_error(). why you chose the three errnos? what about others? eager for Ur replay. Thanks!! --- Best Regards, Liu Wenyi 2010/11/25, Miao Xie : > From: Liu Bo > > This patch provide a new error handle interface for those errors that > handled > by current BUG_ONs. > > In order to protect btrfs from panic, when it comes to those BUG_ON errors, > the interface forces btrfs readonly and saves the FS state to disk. And the > filesystem can be umounted, although with some warning in kernel dmesg. > Then btrfsck is helpful to recover btrfs. > > Signed-off-by: Liu Bo > Signed-off-by: Miao Xie > --- > fs/btrfs/ctree.h |8 + > fs/btrfs/super.c | 88 > ++ > 2 files changed, 96 insertions(+), 0 deletions(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index 78b4c34..ccf6aaf 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -2554,6 +2554,14 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char > *buffer, size_t size); > /* super.c */ > int btrfs_parse_options(struct btrfs_root *root, char *options); > int btrfs_sync_fs(struct super_block *sb, int wait); > +void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, > + unsigned int line, int errno); > + > +#define btrfs_std_error(fs_info, errno) \ > +do { \ > + if ((errno))\ > + __btrfs_std_error((fs_info), __func__, __LINE__, (errno));\ > +} while (0) > > /* acl.c */ > #ifdef CONFIG_BTRFS_FS_POSIX_ACL > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index 8299a25..48fac6e 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -54,6 +54,94 @@ > > static const struct super_operations btrfs_super_ops; > > +static const char *btrfs_decode_error(struct btrfs_fs_info *fs_info, int > errno, > + char nbuf[16]) > +{ > + char *errstr = NULL; > + > + switch (errno) { > + case -EIO: > + errstr = "IO failure"; > + break; > + case -ENOMEM: > + errstr = "Out of memory"; > + break; > + case -EROFS: > + errstr = "Readonly filesystem"; > + break; > + default: > + if (nbuf) { > + if (snprintf(nbuf, 16, "error %d", -errno) >= 0) > + errstr = nbuf; > + } > + break; > + } > + > + return errstr; > +} > + > +static void __save_error_info(struct btrfs_fs_info *fs_info) > +{ > + struct btrfs_super_block *disk_super = &fs_info->super_copy; > + > + fs_info->fs_state = BTRFS_SUPER_FLAG_ERROR; > + disk_super->flags &= cpu_to_le64(~BTRFS_SUPER_FLAG_VALID); > + disk_super->flags |= cpu_to_le64(BTRFS_SUPER_FLAG_ERROR); > + > + mutex_lock(&fs_info->trans_mutex); > + > + memcpy(&fs_info->super_for_commit, disk_super, > +sizeof(fs_info->super_for_commit)); > + > + mutex_unlock(&fs_info->trans_mutex); > +} > + > +static void save_error_info(struct btrfs_fs_info *fs_info) > +{ > + __save_error_info(fs_info); > + write_ctree_super(NULL, btrfs_sb(fs_info->sb), 0); > +} > + > +/* btrfs handle error by forcing the filesystem readonly */ > +static void btrfs_handle_error(struct btrfs_fs_info *fs_info) > +{ > + struct super_block *sb = fs_info->sb; > + > + if (sb->s_flags & MS_RDONLY) > + return; > + > + if (fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { > + sb->s_flags |= MS_RDONLY; > + printk(KERN_INFO "btrfs is forced readonly\n"); > + } > +} > + > +/* > + * __btrfs_std_error decodes expected errors from the caller and > + * invokes the approciate error response. > + */ > +void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, > + unsigned int line, int errno) > +{ > + struct super_block *sb = fs_info->sb; > + char nbuf[16]; > + const char *errstr; > + > + /* > + * Special case: if the error is EROFS, and we're already > + * under MS_RDONLY, then it is safe here. > + */ > + if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) > + return; > + > + errstr = btrfs_decode_error(fs_info, errno, nbuf); > + printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: %s\n", > + sb->s_id, function, line, errstr); > + save_error_info(fs_info); > + > + btrfs_handle_error(fs_info); > +} > + > static void btrfs_put_super(struct super_block *sb) > { > struct btrfs_root *root = btrfs_sb(sb); > -- > 1.7.0.1 > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe l
Re: [RFC PATCH 0/4] Add readonly support to replace BUG_ON phrase
2010/11/25, Miao Xie : > Btrfs has a number of BUG_ON()s, which may lead btrfs to unpleasant panic. > Meanwhile, they are very ugly and should be handled more propriately. > > There are mainly two ways to deal with these BUG_ON()s. Yes, I agree. > > 1. For those errors which can be handled well by callers, we just return > their > error number to callers. It's a good idea. > > 2. For others, We can force the filesystem readonly when it hits errors, > which > is what this patchset has done. Replaced BUG_ON() with the interface > provided > in this patchset, we will get error infomation via dmesg. Since btrfs is > now > readonly, we can save our data safely and umount it, then a btrfsck is > recommended. > > By these ways, we can protect our filesystem from panic caused by those > BUG_ONs. > > --- > fs/btrfs/ctree.h | 21 ++ > fs/btrfs/disk-io.c | 23 +++ > fs/btrfs/super.c | 100 > ++- > fs/btrfs/transaction.c |7 +++ > 4 files changed, 148 insertions(+), 3 deletions(-) > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: btrfs problems and fedora 14
2010/11/23, david grant : > I thought I would try btrfs on a new installation of f14. yes, I know > its experimental but stable so it seemed to be a good time to try it. > I am not sure if I have missed something out of all my searching but am > I correct in thinking that currently: > I. it is not possible to boot from a snapshot of the operating > system and, in particular, the yum snapshots cannot be used for > that purpose Is the Fedora grub support btrfs now? In this page http://fedoraproject.org/wiki/Features/SystemRollbackWithBtrfs I got the following information: (deferred) a patch to grub1 -- on top of the already existing patch to support btrfs in grub1 -- to allow selecting between snapshots of the boot partition. > II. it is so easy to create raid arrays of btrfs partitions but they > cannot be read by f13 or f14 >III. it is not possible to copy btrfs partitions with snapshots > except possibly by the use of dd. > This is not meant to be a put down of btrfs but a plea to have some > clarification and in particular the ability to boot snapshots. > > Hope I can get a response > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: NFS support
Thank you, I will choose another one. 2010/11/10, Josef Bacik : > On Wed, Nov 10, 2010 at 12:53:59PM +0800, Wenyi Liu wrote: >> Hi All: >> >> I found the project ideas about NFS support in btrfs wiki. But, I >> have long time to disconnect to the btrfs mail list. Can you give me >> the process of the support? Thanks!! >> > > NFS support already is there. Thanks, > > Josef > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
NFS support
Hi All: I found the project ideas about NFS support in btrfs wiki. But, I have long time to disconnect to the btrfs mail list. Can you give me the process of the support? Thanks!! --- Best Regards, Liu wenyi -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: static analysis tool cppcheck meets the btrfs code - four issues
2010/1/19 d binderman : > > > Hello there, > > I just ran the sourceforge tool cppcheck over the source code of the > new Linux kernel 2.6.32.4 > > It said > > 1. > > [./btrfs/free-space-cache.c:600]: (style) Redundant condition. It is safe to > deallocate a NULL pointer > > The source code is > > if (info->bitmap) > kfree(info->bitmap); > > I agree with cppcheck. Suggest delete the if test. > > 2. > > [./btrfs/free-space-cache.c:906]: (style) Redundant condition. It is safe to > deallocate a NULL pointer > > Duplicate. > 3. > > [./btrfs/relocation.c:3278]: (error) Memory leak: cluster > > The source code is > > cluster = kzalloc(sizeof(*cluster), GFP_NOFS); > if (!cluster) > return -ENOMEM; > > path = btrfs_alloc_path(); > if (!path) > return -ENOMEM; > > Suggest new code > > cluster = kzalloc(sizeof(*cluster), GFP_NOFS); > if (!cluster) > return -ENOMEM; > > path = btrfs_alloc_path(); > if (!path) > { > kfree( cluster); > return -ENOMEM; > } sounds good, but the code format... > > 4. > > [./btrfs/volumes.c:1257]: (error) Possible null pointer dereference: > fs_devices > > The source code is > > while (fs_devices) { > if (fs_devices->seed == device->fs_devices) > break; > fs_devices = fs_devices->seed; > } > fs_devices->seed = device->fs_devices->seed; > > So presumably fs_devices can never be NULL i.e. the while loop will > always find what it is looking for and so no code to test for NULL is > required. > > > Regards > > David Binderman > > > > _ > Do you have a story that started on Hotmail? Tell us now > http://clk.atdmt.com/UKM/go/195013117/direct/01/-- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html