Skip to content

Commit 89a897f

Browse files
committed
Merge tag 'for-linus' of git://github.com/prasad-joshi/logfs_upstream
Pull LogFS bugfixes from Prasad Joshi: - "logfs: query block device for number of pages to send with bio" This BUG was found when LogFS was used on KVM. The patch fixes the problem by asking for underlaying block device the number of pages to send with each BIO. - "logfs: maintain the ordering of meta-inode destruction" LogFS maintains file system meta-data in special inodes. These inodes are releated to each other, therefore they must be destroyed in a proper order. - "logfs: initialize the number of iovecs in bio" LogFS used to panic when it was created on an encrypted LVM volume. The patch fixes the problem by properly initializing the BIO. Plus a couple more: - logfs: create a pagecache page if it is not present - logfs: destroy the reserved inodes while unmounting * tag 'for-linus' of git://github.com/prasad-joshi/logfs_upstream: logfs: query block device for number of pages to send with bio logfs: maintain the ordering of meta-inode destruction logfs: create a pagecache page if it is not present logfs: initialize the number of iovecs in bio logfs: destroy the reserved inodes while unmounting
2 parents 9acb172 + 9f0bbd8 commit 89a897f

5 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎fs/logfs/dev_bdev.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static int sync_request(struct page *page, struct block_device *bdev, int rw)
2626
struct completion complete;
2727

2828
bio_init(&bio);
29+
bio.bi_max_vecs = 1;
2930
bio.bi_io_vec = &bio_vec;
3031
bio_vec.bv_page = page;
3132
bio_vec.bv_len = PAGE_SIZE;
@@ -95,12 +96,11 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
9596
struct address_space *mapping = super->s_mapping_inode->i_mapping;
9697
struct bio *bio;
9798
struct page *page;
98-
struct request_queue *q = bdev_get_queue(sb->s_bdev);
99-
unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
99+
unsigned int max_pages;
100100
int i;
101101

102-
if (max_pages > BIO_MAX_PAGES)
103-
max_pages = BIO_MAX_PAGES;
102+
max_pages = min(nr_pages, (size_t) bio_get_nr_vecs(super->s_bdev));
103+
104104
bio = bio_alloc(GFP_NOFS, max_pages);
105105
BUG_ON(!bio);
106106

@@ -190,12 +190,11 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index,
190190
{
191191
struct logfs_super *super = logfs_super(sb);
192192
struct bio *bio;
193-
struct request_queue *q = bdev_get_queue(sb->s_bdev);
194-
unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
193+
unsigned int max_pages;
195194
int i;
196195

197-
if (max_pages > BIO_MAX_PAGES)
198-
max_pages = BIO_MAX_PAGES;
196+
max_pages = min(nr_pages, (size_t) bio_get_nr_vecs(super->s_bdev));
197+
199198
bio = bio_alloc(GFP_NOFS, max_pages);
200199
BUG_ON(!bio);
201200

‎fs/logfs/inode.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,26 @@ static void __logfs_destroy_inode(struct inode *inode)
156156
call_rcu(&inode->i_rcu, logfs_i_callback);
157157
}
158158

159+
static void __logfs_destroy_meta_inode(struct inode *inode)
160+
{
161+
struct logfs_inode *li = logfs_inode(inode);
162+
BUG_ON(li->li_block);
163+
call_rcu(&inode->i_rcu, logfs_i_callback);
164+
}
165+
159166
static void logfs_destroy_inode(struct inode *inode)
160167
{
161168
struct logfs_inode *li = logfs_inode(inode);
162169

170+
if (inode->i_ino < LOGFS_RESERVED_INOS) {
171+
/*
172+
* The reserved inodes are never destroyed unless we are in
173+
* unmont path.
174+
*/
175+
__logfs_destroy_meta_inode(inode);
176+
return;
177+
}
178+
163179
BUG_ON(list_empty(&li->li_freeing_list));
164180
spin_lock(&logfs_inode_lock);
165181
li->li_refcount--;
@@ -373,8 +389,8 @@ static void logfs_put_super(struct super_block *sb)
373389
{
374390
struct logfs_super *super = logfs_super(sb);
375391
/* kill the meta-inodes */
376-
iput(super->s_master_inode);
377392
iput(super->s_segfile_inode);
393+
iput(super->s_master_inode);
378394
iput(super->s_mapping_inode);
379395
}
380396

‎fs/logfs/journal.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static void write_wbuf(struct super_block *sb, struct logfs_area *area,
565565
index = ofs >> PAGE_SHIFT;
566566
page_ofs = ofs & (PAGE_SIZE - 1);
567567

568-
page = find_lock_page(mapping, index);
568+
page = find_or_create_page(mapping, index, GFP_NOFS);
569569
BUG_ON(!page);
570570
memcpy(wbuf, page_address(page) + page_ofs, super->s_writesize);
571571
unlock_page(page);

‎fs/logfs/readwrite.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,6 @@ void logfs_evict_inode(struct inode *inode)
21892189
return;
21902190
}
21912191

2192-
BUG_ON(inode->i_ino < LOGFS_RESERVED_INOS);
21932192
page = inode_to_page(inode);
21942193
BUG_ON(!page); /* FIXME: Use emergency page */
21952194
logfs_put_write_page(page);

‎fs/logfs/segment.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ static struct logfs_area *alloc_area(struct super_block *sb)
886886

887887
static void map_invalidatepage(struct page *page, unsigned long l)
888888
{
889-
BUG();
889+
return;
890890
}
891891

892892
static int map_releasepage(struct page *page, gfp_t g)

0 commit comments

Comments
 (0)