From mboxrd@z Thu Jan 1 00:00:00 1970 From: hujianyang Subject: Re: [PATCH 14/18] f2fs crypto: add filename encryption for f2fs_lookup Date: Mon, 11 May 2015 10:52:48 +0800 Message-ID: <55501980.7040206@huawei.com> References: <1431145253-2019-1-git-send-email-jaegeuk@kernel.org> <1431145253-2019-14-git-send-email-jaegeuk@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Return-path: Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YrdqF-0000St-Bc for linux-f2fs-devel@lists.sourceforge.net; Mon, 11 May 2015 02:53:15 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YrdqC-0003b1-00 for linux-f2fs-devel@lists.sourceforge.net; Mon, 11 May 2015 02:53:15 +0000 In-Reply-To: <1431145253-2019-14-git-send-email-jaegeuk@kernel.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Jaegeuk Kim Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Hi Jaegeuk, While compiling git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.= git branch dev(commit 5af6e74892a f2fs crypto: remove checking key context duri= ng lookup), I saw an error: fs/f2fs/dir.c: In function =91find_in_level=92: fs/f2fs/dir.c:163: error: unknown field =91len=92 specified in initializer fs/f2fs/dir.c:163: warning: excess elements in struct initializer fs/f2fs/dir.c:163: warning: (near initialization for =91name=92) I think it's related to this patch. If there is anything wrong in my configuration, please let me know. Thanks, Hu On 2015/5/9 12:20, Jaegeuk Kim wrote: > This patch implements filename encryption support for f2fs_lookup. > = > Note that, f2fs_find_entry should be outside of f2fs_(un)lock_op(). > = > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/dir.c | 79 ++++++++++++++++++++++++++++++++------------------= ------ > fs/f2fs/f2fs.h | 9 ++++--- > fs/f2fs/inline.c | 9 ++++--- > 3 files changed, 56 insertions(+), 41 deletions(-) > = > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c > index ab6455d..5e10d9d 100644 > --- a/fs/f2fs/dir.c > +++ b/fs/f2fs/dir.c > @@ -76,20 +76,10 @@ static unsigned long dir_block_index(unsigned int lev= el, > return bidx; > } > = > -static bool early_match_name(size_t namelen, f2fs_hash_t namehash, > - struct f2fs_dir_entry *de) > -{ > - if (le16_to_cpu(de->name_len) !=3D namelen) > - return false; > - > - if (de->hash_code !=3D namehash) > - return false; > - > - return true; > -} > - > static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, > - struct qstr *name, int *max_slots, > + struct f2fs_filename *fname, > + f2fs_hash_t namehash, > + int *max_slots, > struct page **res_page) > { > struct f2fs_dentry_block *dentry_blk; > @@ -99,8 +89,7 @@ static struct f2fs_dir_entry *find_in_block(struct page= *dentry_page, > dentry_blk =3D (struct f2fs_dentry_block *)kmap(dentry_page); > = > make_dentry_ptr(NULL, &d, (void *)dentry_blk, 1); > - de =3D find_target_dentry(name, max_slots, &d); > - > + de =3D find_target_dentry(fname, namehash, max_slots, &d); > if (de) > *res_page =3D dentry_page; > else > @@ -114,13 +103,15 @@ static struct f2fs_dir_entry *find_in_block(struct = page *dentry_page, > return de; > } > = > -struct f2fs_dir_entry *find_target_dentry(struct qstr *name, int *max_sl= ots, > - struct f2fs_dentry_ptr *d) > +struct f2fs_dir_entry *find_target_dentry(struct f2fs_filename *fname, > + f2fs_hash_t namehash, int *max_slots, > + struct f2fs_dentry_ptr *d) > { > struct f2fs_dir_entry *de; > unsigned long bit_pos =3D 0; > - f2fs_hash_t namehash =3D f2fs_dentry_hash(name); > int max_len =3D 0; > + struct f2fs_str de_name =3D FSTR_INIT(NULL, 0); > + struct f2fs_str *name =3D &fname->disk_name; > = > if (max_slots) > *max_slots =3D 0; > @@ -132,8 +123,18 @@ struct f2fs_dir_entry *find_target_dentry(struct qst= r *name, int *max_slots, > } > = > de =3D &d->dentry[bit_pos]; > - if (early_match_name(name->len, namehash, de) && > - !memcmp(d->filename[bit_pos], name->name, name->len)) > + > + /* encrypted case */ > + de_name.name =3D d->filename[bit_pos]; > + de_name.len =3D le16_to_cpu(de->name_len); > + > + /* show encrypted name */ > + if (fname->hash) { > + if (de->hash_code =3D=3D fname->hash) > + goto found; > + } else if (de_name.len =3D=3D name->len && > + de->hash_code =3D=3D namehash && > + !memcmp(de_name.name, name->name, name->len)) > goto found; > = > if (max_slots && max_len > *max_slots) > @@ -155,16 +156,21 @@ found: > } > = > static struct f2fs_dir_entry *find_in_level(struct inode *dir, > - unsigned int level, struct qstr *name, > - f2fs_hash_t namehash, struct page **res_page) > + unsigned int level, > + struct f2fs_filename *fname, > + struct page **res_page) > { > - int s =3D GET_DENTRY_SLOTS(name->len); > + struct qstr name =3D FSTR_TO_QSTR(&fname->disk_name); > + int s =3D GET_DENTRY_SLOTS(name.len); > unsigned int nbucket, nblock; > unsigned int bidx, end_block; > struct page *dentry_page; > struct f2fs_dir_entry *de =3D NULL; > bool room =3D false; > int max_slots; > + f2fs_hash_t namehash; > + > + namehash =3D f2fs_dentry_hash(&name); > = > f2fs_bug_on(F2FS_I_SB(dir), level > MAX_DIR_HASH_DEPTH); > = > @@ -183,7 +189,8 @@ static struct f2fs_dir_entry *find_in_level(struct in= ode *dir, > continue; > } > = > - de =3D find_in_block(dentry_page, name, &max_slots, res_page); > + de =3D find_in_block(dentry_page, fname, namehash, &max_slots, > + res_page); > if (de) > break; > = > @@ -211,30 +218,34 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode= *dir, > { > unsigned long npages =3D dir_blocks(dir); > struct f2fs_dir_entry *de =3D NULL; > - f2fs_hash_t name_hash; > unsigned int max_depth; > unsigned int level; > + struct f2fs_filename fname; > + int err; > = > *res_page =3D NULL; > = > - if (f2fs_has_inline_dentry(dir)) > - return find_in_inline_dir(dir, child, res_page); > + err =3D f2fs_fname_setup_filename(dir, child, 1, &fname); > + if (err) > + return NULL; > + > + if (f2fs_has_inline_dentry(dir)) { > + de =3D find_in_inline_dir(dir, &fname, res_page); > + goto out; > + } > = > if (npages =3D=3D 0) > - return NULL; > + goto out; > = > - name_hash =3D f2fs_dentry_hash(child); > max_depth =3D F2FS_I(dir)->i_current_depth; > = > for (level =3D 0; level < max_depth; level++) { > - de =3D find_in_level(dir, level, child, name_hash, res_page); > + de =3D find_in_level(dir, level, &fname, res_page); > if (de) > break; > } > - if (!de && F2FS_I(dir)->chash !=3D name_hash) { > - F2FS_I(dir)->chash =3D name_hash; > - F2FS_I(dir)->clevel =3D level - 1; > - } > +out: > + f2fs_fname_free_filename(&fname); > return de; > } > = > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 963616f..6898331 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -1584,8 +1584,9 @@ struct dentry *f2fs_get_parent(struct dentry *child= ); > */ > extern unsigned char f2fs_filetype_table[F2FS_FT_MAX]; > void set_de_type(struct f2fs_dir_entry *, umode_t); > -struct f2fs_dir_entry *find_target_dentry(struct qstr *, int *, > - struct f2fs_dentry_ptr *); > + > +struct f2fs_dir_entry *find_target_dentry(struct f2fs_filename *, > + f2fs_hash_t, int *, struct f2fs_dentry_ptr *); > bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *, > unsigned int, struct f2fs_str *); > void do_make_empty_dir(struct inode *, struct inode *, > @@ -1931,8 +1932,8 @@ int f2fs_convert_inline_page(struct dnode_of_data *= , struct page *); > int f2fs_convert_inline_inode(struct inode *); > int f2fs_write_inline_data(struct inode *, struct page *); > bool recover_inline_data(struct inode *, struct page *); > -struct f2fs_dir_entry *find_in_inline_dir(struct inode *, struct qstr *, > - struct page **); > +struct f2fs_dir_entry *find_in_inline_dir(struct inode *, > + struct f2fs_filename *, struct page **); > struct f2fs_dir_entry *f2fs_parent_inline_dir(struct inode *, struct pag= e **); > int make_empty_inline_dir(struct inode *inode, struct inode *, struct pa= ge *); > int f2fs_add_inline_entry(struct inode *, const struct qstr *, struct in= ode *, > diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c > index dd51d3f..38e75fb 100644 > --- a/fs/f2fs/inline.c > +++ b/fs/f2fs/inline.c > @@ -284,23 +284,26 @@ process_inline: > } > = > struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir, > - struct qstr *name, struct page **res_page) > + struct f2fs_filename *fname, struct page **res_page) > { > struct f2fs_sb_info *sbi =3D F2FS_SB(dir->i_sb); > struct f2fs_inline_dentry *inline_dentry; > + struct qstr name =3D FSTR_TO_QSTR(&fname->disk_name); > struct f2fs_dir_entry *de; > struct f2fs_dentry_ptr d; > struct page *ipage; > + f2fs_hash_t namehash; > = > ipage =3D get_node_page(sbi, dir->i_ino); > if (IS_ERR(ipage)) > return NULL; > = > + namehash =3D f2fs_dentry_hash(&name); > + > inline_dentry =3D inline_data_addr(ipage); > = > make_dentry_ptr(NULL, &d, (void *)inline_dentry, 2); > - de =3D find_target_dentry(name, NULL, &d); > - > + de =3D find_target_dentry(fname, namehash, NULL, &d); > unlock_page(ipage); > if (de) > *res_page =3D ipage; > = ---------------------------------------------------------------------------= --- One dashboard for servers and applications across Physical-Virtual-Cloud = Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y