Skip to content

Commit b0fd669

Browse files
Jaegeuk Kimpundiramit
authored andcommitted
f2fs: catch up to v4.14-rc1
This is cherry-picked from upstrea-f2fs-stable-linux-4.4.y. Changes include: commit c7fd9e2 ("f2fs: hurry up to issue discard after io interruption") commit 603dde3 ("f2fs: fix to show correct discard_granularity in sysfs") ... commit 565f022 ("f2fs: factor out discard command info into discard_cmd_control") commit c4cc29d ("f2fs: remove batched discard in f2fs_trim_fs") Change-Id: Icd8a85ac0c19a8aa25cd2591a12b4e9b85bdf1c5 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
1 parent 406cbca commit b0fd669

45 files changed

Lines changed: 7567 additions & 3458 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ Contact: "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
5757
Description:
5858
Controls the issue rate of small discard commands.
5959

60+
What: /sys/fs/f2fs/<disk>/discard_granularity
61+
Date: July 2017
62+
Contact: "Chao Yu" <yuchao0@huawei.com>
63+
Description:
64+
Controls discard granularity of inner discard thread, inner thread
65+
will not issue discards with size that is smaller than granularity.
66+
The unit size is one block, now only support configuring in range
67+
of [1, 512].
68+
6069
What: /sys/fs/f2fs/<disk>/max_victim_search
6170
Date: January 2014
6271
Contact: "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
@@ -92,3 +101,47 @@ Date: October 2015
92101
Contact: "Chao Yu" <chao2.yu@samsung.com>
93102
Description:
94103
Controls the count of nid pages to be readaheaded.
104+
105+
What: /sys/fs/f2fs/<disk>/dirty_nats_ratio
106+
Date: January 2016
107+
Contact: "Chao Yu" <chao2.yu@samsung.com>
108+
Description:
109+
Controls dirty nat entries ratio threshold, if current
110+
ratio exceeds configured threshold, checkpoint will
111+
be triggered for flushing dirty nat entries.
112+
113+
What: /sys/fs/f2fs/<disk>/lifetime_write_kbytes
114+
Date: January 2016
115+
Contact: "Shuoran Liu" <liushuoran@huawei.com>
116+
Description:
117+
Shows total written kbytes issued to disk.
118+
119+
What: /sys/fs/f2fs/<disk>/inject_rate
120+
Date: May 2016
121+
Contact: "Sheng Yong" <shengyong1@huawei.com>
122+
Description:
123+
Controls the injection rate.
124+
125+
What: /sys/fs/f2fs/<disk>/inject_type
126+
Date: May 2016
127+
Contact: "Sheng Yong" <shengyong1@huawei.com>
128+
Description:
129+
Controls the injection type.
130+
131+
What: /sys/fs/f2fs/<disk>/reserved_blocks
132+
Date: June 2017
133+
Contact: "Chao Yu" <yuchao0@huawei.com>
134+
Description:
135+
Controls current reserved blocks in system.
136+
137+
What: /sys/fs/f2fs/<disk>/gc_urgent
138+
Date: August 2017
139+
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
140+
Description:
141+
Do background GC agressively
142+
143+
What: /sys/fs/f2fs/<disk>/gc_urgent_sleep_time
144+
Date: August 2017
145+
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
146+
Description:
147+
Controls sleep time of GC urgent mode

Documentation/filesystems/f2fs.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ active_logs=%u Support configuring the number of active logs. In the
125125
disable_ext_identify Disable the extension list configured by mkfs, so f2fs
126126
does not aware of cold files such as media files.
127127
inline_xattr Enable the inline xattrs feature.
128+
noinline_xattr Disable the inline xattrs feature.
128129
inline_data Enable the inline data feature: New created small(<~3.4k)
129130
files can be written into inode block.
130131
inline_dentry Enable the inline dir feature: data in new created
@@ -159,6 +160,18 @@ mode=%s Control block allocation mode which supports "adaptive"
159160
writes towards main area.
160161
io_bits=%u Set the bit size of write IO requests. It should be set
161162
with "mode=lfs".
163+
usrquota Enable plain user disk quota accounting.
164+
grpquota Enable plain group disk quota accounting.
165+
prjquota Enable plain project quota accounting.
166+
usrjquota=<file> Appoint specified file and type during mount, so that quota
167+
grpjquota=<file> information can be properly updated during recovery flow,
168+
prjjquota=<file> <quota file>: must be in root directory;
169+
jqfmt=<quota type> <quota type>: [vfsold,vfsv0,vfsv1].
170+
offusrjquota Turn off user journelled quota.
171+
offgrpjquota Turn off group journelled quota.
172+
offprjjquota Turn off project journelled quota.
173+
quota Enable plain user disk quota accounting.
174+
noquota Disable all plain disk quota option.
162175

163176
================================================================================
164177
DEBUGFS ENTRIES
@@ -204,6 +217,15 @@ Files in /sys/fs/f2fs/<devname>
204217
gc_idle = 1 will select the Cost Benefit approach
205218
& setting gc_idle = 2 will select the greedy approach.
206219

220+
gc_urgent This parameter controls triggering background GCs
221+
urgently or not. Setting gc_urgent = 0 [default]
222+
makes back to default behavior, while if it is set
223+
to 1, background thread starts to do GC by given
224+
gc_urgent_sleep_time interval.
225+
226+
gc_urgent_sleep_time This parameter controls sleep time for gc_urgent.
227+
500 ms is set by default. See above gc_urgent.
228+
207229
reclaim_segments This parameter controls the number of prefree
208230
segments to be reclaimed. If the number of prefree
209231
segments is larger than the number of segments

fs/crypto/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
obj-$(CONFIG_FS_ENCRYPTION) += fscrypto.o
22

33
fscrypto-y := crypto.o fname.o policy.o keyinfo.o
4+
fscrypto-$(CONFIG_BLOCK) += bio.o

fs/crypto/bio.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* This contains encryption functions for per-file encryption.
3+
*
4+
* Copyright (C) 2015, Google, Inc.
5+
* Copyright (C) 2015, Motorola Mobility
6+
*
7+
* Written by Michael Halcrow, 2014.
8+
*
9+
* Filename encryption additions
10+
* Uday Savagaonkar, 2014
11+
* Encryption policy handling additions
12+
* Ildar Muslukhov, 2014
13+
* Add fscrypt_pullback_bio_page()
14+
* Jaegeuk Kim, 2015.
15+
*
16+
* This has not yet undergone a rigorous security audit.
17+
*
18+
* The usage of AES-XTS should conform to recommendations in NIST
19+
* Special Publication 800-38E and IEEE P1619/D16.
20+
*/
21+
22+
#include <linux/pagemap.h>
23+
#include <linux/module.h>
24+
#include <linux/bio.h>
25+
#include <linux/namei.h>
26+
#include "fscrypt_private.h"
27+
28+
/*
29+
* Call fscrypt_decrypt_page on every single page, reusing the encryption
30+
* context.
31+
*/
32+
static void completion_pages(struct work_struct *work)
33+
{
34+
struct fscrypt_ctx *ctx =
35+
container_of(work, struct fscrypt_ctx, r.work);
36+
struct bio *bio = ctx->r.bio;
37+
struct bio_vec *bv;
38+
int i;
39+
40+
bio_for_each_segment_all(bv, bio, i) {
41+
struct page *page = bv->bv_page;
42+
int ret = fscrypt_decrypt_page(page->mapping->host, page,
43+
PAGE_SIZE, 0, page->index);
44+
45+
if (ret) {
46+
WARN_ON_ONCE(1);
47+
SetPageError(page);
48+
} else {
49+
SetPageUptodate(page);
50+
}
51+
unlock_page(page);
52+
}
53+
fscrypt_release_ctx(ctx);
54+
bio_put(bio);
55+
}
56+
57+
void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, struct bio *bio)
58+
{
59+
INIT_WORK(&ctx->r.work, completion_pages);
60+
ctx->r.bio = bio;
61+
queue_work(fscrypt_read_workqueue, &ctx->r.work);
62+
}
63+
EXPORT_SYMBOL(fscrypt_decrypt_bio_pages);
64+
65+
void fscrypt_pullback_bio_page(struct page **page, bool restore)
66+
{
67+
struct fscrypt_ctx *ctx;
68+
struct page *bounce_page;
69+
70+
/* The bounce data pages are unmapped. */
71+
if ((*page)->mapping)
72+
return;
73+
74+
/* The bounce data page is unmapped. */
75+
bounce_page = *page;
76+
ctx = (struct fscrypt_ctx *)page_private(bounce_page);
77+
78+
/* restore control page */
79+
*page = ctx->w.control_page;
80+
81+
if (restore)
82+
fscrypt_restore_control_page(bounce_page);
83+
}
84+
EXPORT_SYMBOL(fscrypt_pullback_bio_page);
85+
86+
int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
87+
sector_t pblk, unsigned int len)
88+
{
89+
struct fscrypt_ctx *ctx;
90+
struct page *ciphertext_page = NULL;
91+
struct bio *bio;
92+
int ret, err = 0;
93+
94+
BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE);
95+
96+
ctx = fscrypt_get_ctx(inode, GFP_NOFS);
97+
if (IS_ERR(ctx))
98+
return PTR_ERR(ctx);
99+
100+
ciphertext_page = fscrypt_alloc_bounce_page(ctx, GFP_NOWAIT);
101+
if (IS_ERR(ciphertext_page)) {
102+
err = PTR_ERR(ciphertext_page);
103+
goto errout;
104+
}
105+
106+
while (len--) {
107+
err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk,
108+
ZERO_PAGE(0), ciphertext_page,
109+
PAGE_SIZE, 0, GFP_NOFS);
110+
if (err)
111+
goto errout;
112+
113+
bio = bio_alloc(GFP_NOWAIT, 1);
114+
if (!bio) {
115+
err = -ENOMEM;
116+
goto errout;
117+
}
118+
bio->bi_bdev = inode->i_sb->s_bdev;
119+
bio->bi_iter.bi_sector =
120+
pblk << (inode->i_sb->s_blocksize_bits - 9);
121+
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
122+
ret = bio_add_page(bio, ciphertext_page,
123+
inode->i_sb->s_blocksize, 0);
124+
if (ret != inode->i_sb->s_blocksize) {
125+
/* should never happen! */
126+
WARN_ON(1);
127+
bio_put(bio);
128+
err = -EIO;
129+
goto errout;
130+
}
131+
err = submit_bio_wait(0, bio);
132+
bio_put(bio);
133+
if (err)
134+
goto errout;
135+
lblk++;
136+
pblk++;
137+
}
138+
err = 0;
139+
errout:
140+
fscrypt_release_ctx(ctx);
141+
return err;
142+
}
143+
EXPORT_SYMBOL(fscrypt_zeroout_range);

0 commit comments

Comments
 (0)