All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Matt <jackdachef@gmail.com>,
	gregkh@suse.de, Chris Mason <chris.mason@oracle.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	ngupta@vflare.org, linux-btrfs@vger.kernel.org,
	Josef Bacik <josef@redhat.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Yan Zheng <zheng.z.yan@intel.com>,
	miaox@cn.fujitsu.com, Li Zefan <lizf@cn.fujitsu.com>
Subject: RE: [PATCH V2 0/3] drivers/staging: zcache: dynamic page cache/swap compression
Date: Thu, 3 Mar 2011 09:29:04 -0800 (PST)	[thread overview]
Message-ID: <763a2305-27c6-4f44-8962-db72b434c037@default> (raw)
In-Reply-To: <AANLkTim_U+mJtHk7drvqMOmUwd4ro8J0dazZMDsNqH=o@mail.gmail.com>

> > I definitely see a bug in cleancache_get_key in the monolithic
> > zcache+cleancache+frontswap patch I posted on oss.oracle.com
> > that is corrected in linux-next but I don't see how it could
> > get provoked by btrfs.
> >
> > The bug is that, in cleancache_get_key, the return value of fhfn
> should
> > be checked against 255. =C2=A0If the return value is 255,
> cleancache_get_key
> > should return -1. =C2=A0This should disable cleancache for any filesyst=
em
> > where KEY_MAX is too large.
> >
> > But cleancache_get_key always calls fhfn with connectable =3D=3D 0 and
> > CLEANCACHE_KEY_MAX=3D=3D6 should be greater than
> BTRFS_FID_SIZE_CONNECTABLE
> > (which I think should be 5?). =C2=A0And the elements written into the
> > typecast btrfs_fid should be only writing the first 5 32-bit words.
>=20
> BTRFS_FID_SIZE_NON_CONNECTALBE is 5,  not BTRFS_FID_SIZE_CONNECTABLE.
> Anyway, you passed connectable with 0 so it should be only writing the
> first 5 32-bit words as you said.
> That's one I missed. ;-)
>=20
> Thanks.
> --
> Kind regards,
> Minchan Kim

Sorry, I realized that I solved this with Matt offlist and never
posted the solution on-list, so for the archives:

This patch applies on top of the cleancache patch.  It is really
a horrible hack but solving it correctly requires the interface
to encode_fh ops to change, which would require changes to many
filesystems, so best saved for a later time.  If/when cleancache
gets merged, this patch will need to be applied on top of it
for btrfs to work properly when cleancache is enabled.

Basically, the problem is that, in all current filesystems,
obtaining the filehandle requires a dentry ONLY if connectable
is set.  Otherwise, the dentry is only used to get the inode.
But cleancache_get_key only has an inode, and the alias list
of dentries associated with the inode may be empty.  So
either the encode_fh interface would need to be changed
or, in this hack-y solution, a dentry is created temporarily
only for the purpose of dereferencing it.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>

diff -Napur -X linux-2.6.37.1/Documentation/dontdiff linux-2.6.37.1/mm/clea=
ncache.c linux-2.6.37.1-fix/mm/cleancache.c
--- linux-2.6.37.1/mm/cleancache.c=092011-02-25 11:38:47.000000000 -0800
+++ linux-2.6.37.1-fix/mm/cleancache.c=092011-02-25 08:53:46.000000000 -080=
0
@@ -78,15 +78,14 @@ static int cleancache_get_key(struct ino
 =09int (*fhfn)(struct dentry *, __u32 *fh, int *, int);
 =09int maxlen =3D CLEANCACHE_KEY_MAX;
 =09struct super_block *sb =3D inode->i_sb;
-=09struct dentry *d;
=20
 =09key->u.ino =3D inode->i_ino;
 =09if (sb->s_export_op !=3D NULL) {
 =09=09fhfn =3D sb->s_export_op->encode_fh;
 =09=09if  (fhfn) {
-=09=09=09d =3D list_first_entry(&inode->i_dentry,
-=09=09=09=09=09=09struct dentry, d_alias);
-=09=09=09(void)(*fhfn)(d, &key->u.fh[0], &maxlen, 0);
+=09=09=09struct dentry d;
+=09=09=09d.d_inode =3D inode;
+=09=09=09(void)(*fhfn)(&d, &key->u.fh[0], &maxlen, 0);
 =09=09=09if (maxlen > CLEANCACHE_KEY_MAX)
 =09=09=09=09return -1;
 =09=09}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Matt <jackdachef@gmail.com>,
	gregkh@suse.de, Chris Mason <chris.mason@oracle.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	ngupta@vflare.org, linux-btrfs@vger.kernel.org,
	Josef Bacik <josef@redhat.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Yan Zheng <zheng.z.yan@intel.com>,
	miaox@cn.fujitsu.com, Li Zefan <lizf@cn.fujitsu.com>
Subject: RE: [PATCH V2 0/3] drivers/staging: zcache: dynamic page cache/swap compression
Date: Thu, 3 Mar 2011 09:29:04 -0800 (PST)	[thread overview]
Message-ID: <763a2305-27c6-4f44-8962-db72b434c037@default> (raw)
In-Reply-To: <AANLkTim_U+mJtHk7drvqMOmUwd4ro8J0dazZMDsNqH=o@mail.gmail.com>

> > I definitely see a bug in cleancache_get_key in the monolithic
> > zcache+cleancache+frontswap patch I posted on oss.oracle.com
> > that is corrected in linux-next but I don't see how it could
> > get provoked by btrfs.
> >
> > The bug is that, in cleancache_get_key, the return value of fhfn
> should
> > be checked against 255.  If the return value is 255,
> cleancache_get_key
> > should return -1.  This should disable cleancache for any filesystem
> > where KEY_MAX is too large.
> >
> > But cleancache_get_key always calls fhfn with connectable == 0 and
> > CLEANCACHE_KEY_MAX==6 should be greater than
> BTRFS_FID_SIZE_CONNECTABLE
> > (which I think should be 5?).  And the elements written into the
> > typecast btrfs_fid should be only writing the first 5 32-bit words.
> 
> BTRFS_FID_SIZE_NON_CONNECTALBE is 5,  not BTRFS_FID_SIZE_CONNECTABLE.
> Anyway, you passed connectable with 0 so it should be only writing the
> first 5 32-bit words as you said.
> That's one I missed. ;-)
> 
> Thanks.
> --
> Kind regards,
> Minchan Kim

Sorry, I realized that I solved this with Matt offlist and never
posted the solution on-list, so for the archives:

This patch applies on top of the cleancache patch.  It is really
a horrible hack but solving it correctly requires the interface
to encode_fh ops to change, which would require changes to many
filesystems, so best saved for a later time.  If/when cleancache
gets merged, this patch will need to be applied on top of it
for btrfs to work properly when cleancache is enabled.

Basically, the problem is that, in all current filesystems,
obtaining the filehandle requires a dentry ONLY if connectable
is set.  Otherwise, the dentry is only used to get the inode.
But cleancache_get_key only has an inode, and the alias list
of dentries associated with the inode may be empty.  So
either the encode_fh interface would need to be changed
or, in this hack-y solution, a dentry is created temporarily
only for the purpose of dereferencing it.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>

diff -Napur -X linux-2.6.37.1/Documentation/dontdiff linux-2.6.37.1/mm/cleancache.c linux-2.6.37.1-fix/mm/cleancache.c
--- linux-2.6.37.1/mm/cleancache.c	2011-02-25 11:38:47.000000000 -0800
+++ linux-2.6.37.1-fix/mm/cleancache.c	2011-02-25 08:53:46.000000000 -0800
@@ -78,15 +78,14 @@ static int cleancache_get_key(struct ino
 	int (*fhfn)(struct dentry *, __u32 *fh, int *, int);
 	int maxlen = CLEANCACHE_KEY_MAX;
 	struct super_block *sb = inode->i_sb;
-	struct dentry *d;
 
 	key->u.ino = inode->i_ino;
 	if (sb->s_export_op != NULL) {
 		fhfn = sb->s_export_op->encode_fh;
 		if  (fhfn) {
-			d = list_first_entry(&inode->i_dentry,
-						struct dentry, d_alias);
-			(void)(*fhfn)(d, &key->u.fh[0], &maxlen, 0);
+			struct dentry d;
+			d.d_inode = inode;
+			(void)(*fhfn)(&d, &key->u.fh[0], &maxlen, 0);
 			if (maxlen > CLEANCACHE_KEY_MAX)
 				return -1;
 		}

WARNING: multiple messages have this Message-ID (diff)
From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Minchan Kim <minchan.kim@gmail.com>
Cc: Matt <jackdachef@gmail.com>,
	gregkh@suse.de, Chris Mason <chris.mason@oracle.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	ngupta@vflare.org, linux-btrfs@vger.kernel.org,
	Josef Bacik <josef@redhat.com>,
	Dan Rosenberg <drosenberg@vsecurity.com>,
	Yan Zheng <zheng.z.yan@intel.com>,
	miaox@cn.fujitsu.com, Li Zefan <lizf@cn.fujitsu.com>
Subject: RE: [PATCH V2 0/3] drivers/staging: zcache: dynamic page cache/swap compression
Date: Thu, 3 Mar 2011 09:29:04 -0800 (PST)	[thread overview]
Message-ID: <763a2305-27c6-4f44-8962-db72b434c037@default> (raw)
In-Reply-To: <AANLkTim_U+mJtHk7drvqMOmUwd4ro8J0dazZMDsNqH=o@mail.gmail.com>

> > I definitely see a bug in cleancache_get_key in the monolithic
> > zcache+cleancache+frontswap patch I posted on oss.oracle.com
> > that is corrected in linux-next but I don't see how it could
> > get provoked by btrfs.
> >
> > The bug is that, in cleancache_get_key, the return value of fhfn
> should
> > be checked against 255.  If the return value is 255,
> cleancache_get_key
> > should return -1.  This should disable cleancache for any filesystem
> > where KEY_MAX is too large.
> >
> > But cleancache_get_key always calls fhfn with connectable == 0 and
> > CLEANCACHE_KEY_MAX==6 should be greater than
> BTRFS_FID_SIZE_CONNECTABLE
> > (which I think should be 5?).  And the elements written into the
> > typecast btrfs_fid should be only writing the first 5 32-bit words.
> 
> BTRFS_FID_SIZE_NON_CONNECTALBE is 5,  not BTRFS_FID_SIZE_CONNECTABLE.
> Anyway, you passed connectable with 0 so it should be only writing the
> first 5 32-bit words as you said.
> That's one I missed. ;-)
> 
> Thanks.
> --
> Kind regards,
> Minchan Kim

Sorry, I realized that I solved this with Matt offlist and never
posted the solution on-list, so for the archives:

This patch applies on top of the cleancache patch.  It is really
a horrible hack but solving it correctly requires the interface
to encode_fh ops to change, which would require changes to many
filesystems, so best saved for a later time.  If/when cleancache
gets merged, this patch will need to be applied on top of it
for btrfs to work properly when cleancache is enabled.

Basically, the problem is that, in all current filesystems,
obtaining the filehandle requires a dentry ONLY if connectable
is set.  Otherwise, the dentry is only used to get the inode.
But cleancache_get_key only has an inode, and the alias list
of dentries associated with the inode may be empty.  So
either the encode_fh interface would need to be changed
or, in this hack-y solution, a dentry is created temporarily
only for the purpose of dereferencing it.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>

diff -Napur -X linux-2.6.37.1/Documentation/dontdiff linux-2.6.37.1/mm/cleancache.c linux-2.6.37.1-fix/mm/cleancache.c
--- linux-2.6.37.1/mm/cleancache.c	2011-02-25 11:38:47.000000000 -0800
+++ linux-2.6.37.1-fix/mm/cleancache.c	2011-02-25 08:53:46.000000000 -0800
@@ -78,15 +78,14 @@ static int cleancache_get_key(struct ino
 	int (*fhfn)(struct dentry *, __u32 *fh, int *, int);
 	int maxlen = CLEANCACHE_KEY_MAX;
 	struct super_block *sb = inode->i_sb;
-	struct dentry *d;
 
 	key->u.ino = inode->i_ino;
 	if (sb->s_export_op != NULL) {
 		fhfn = sb->s_export_op->encode_fh;
 		if  (fhfn) {
-			d = list_first_entry(&inode->i_dentry,
-						struct dentry, d_alias);
-			(void)(*fhfn)(d, &key->u.fh[0], &maxlen, 0);
+			struct dentry d;
+			d.d_inode = inode;
+			(void)(*fhfn)(&d, &key->u.fh[0], &maxlen, 0);
 			if (maxlen > CLEANCACHE_KEY_MAX)
 				return -1;
 		}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-03-03 17:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07  3:24 [PATCH V2 0/3] drivers/staging: zcache: dynamic page cache/swap compression Dan Magenheimer
2011-02-07  3:24 ` Dan Magenheimer
2011-02-09  1:03 ` Dan Magenheimer
2011-02-09  1:03   ` Dan Magenheimer
2011-02-09  2:32   ` Nitin Gupta
2011-02-09  2:32     ` Nitin Gupta
2011-02-14  0:08   ` Matt
2011-02-14  0:08     ` Matt
2011-02-14  1:24     ` Matt
2011-02-14  1:24       ` Matt
2011-02-14  1:29       ` Matt
2011-02-14  1:29         ` Matt
2011-02-14  4:35         ` Minchan Kim
2011-02-14  4:35           ` Minchan Kim
2011-02-16  0:12           ` Matt
2011-02-16  0:12             ` Matt
2011-02-16  0:12             ` Matt
2011-02-16  1:27             ` Dan Magenheimer
2011-02-16  1:27               ` Dan Magenheimer
2011-02-16  1:27               ` Dan Magenheimer
2011-02-16  1:58               ` Matt
2011-02-16  1:58                 ` Matt
2011-02-16  1:58                 ` Matt
2011-02-16  4:36               ` Minchan Kim
2011-02-16  4:36                 ` Minchan Kim
2011-02-16  4:36                 ` Minchan Kim
2011-03-03 17:29                 ` Dan Magenheimer [this message]
2011-03-03 17:29                   ` Dan Magenheimer
2011-03-03 17:29                   ` Dan Magenheimer
2011-02-14 20:59         ` Matt
2011-02-14 20:59           ` Matt
2011-02-15 23:48           ` Matt
2011-02-15 23:48             ` Matt
2011-02-15 23:48             ` Matt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=763a2305-27c6-4f44-8962-db72b434c037@default \
    --to=dan.magenheimer@oracle.com \
    --cc=chris.mason@oracle.com \
    --cc=drosenberg@vsecurity.com \
    --cc=gregkh@suse.de \
    --cc=jackdachef@gmail.com \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=miaox@cn.fujitsu.com \
    --cc=minchan.kim@gmail.com \
    --cc=ngupta@vflare.org \
    --cc=zheng.z.yan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.