* ovl_dir_read_merged: Redundant call to list_add()
@ 2017-05-30 6:39 Chandan Rajendra
2017-05-30 8:05 ` Amir Goldstein
0 siblings, 1 reply; 3+ messages in thread
From: Chandan Rajendra @ 2017-05-30 6:39 UTC (permalink / raw)
To: linux-unionfs@vger.kernel.org; +Cc: Amir Goldstein
ovl_dir_read_merged() has the following loop,
for (idx = 0; idx != -1; idx = next) {
next = ovl_path_next(idx, dentry, &realpath);
if (next != -1) {
err = ovl_dir_read(&realpath, &rdd);
if (err)
break;
} else {
/*
* Insert lowest layer entries before upper ones, this
* allows offsets to be reasonably constant
*/
list_add(&rdd.middle, rdd.list);
rdd.is_lowest = true;
err = ovl_dir_read(&realpath, &rdd);
list_del(&rdd.middle);
}
}
rdd.middle is populated inside ovl_fill_lowest() which is indirectly invoked
by the call to ovl_dir_read() inside the "else" part of the above "if"
condition. Before this invocation of ovl_dir_read(), rdd.middle would
basically be an empty list. So this would mean that the call
list_add(&rdd.middle, rdd.list) is unnecessary.
Please let me know if I am missing something here.
--
chandan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: ovl_dir_read_merged: Redundant call to list_add()
2017-05-30 6:39 ovl_dir_read_merged: Redundant call to list_add() Chandan Rajendra
@ 2017-05-30 8:05 ` Amir Goldstein
2017-05-30 8:47 ` Chandan Rajendra
0 siblings, 1 reply; 3+ messages in thread
From: Amir Goldstein @ 2017-05-30 8:05 UTC (permalink / raw)
To: Chandan Rajendra; +Cc: linux-unionfs@vger.kernel.org
On Tue, May 30, 2017 at 9:39 AM, Chandan Rajendra
<chandan@linux.vnet.ibm.com> wrote:
> ovl_dir_read_merged() has the following loop,
>
> for (idx = 0; idx != -1; idx = next) {
> next = ovl_path_next(idx, dentry, &realpath);
>
> if (next != -1) {
> err = ovl_dir_read(&realpath, &rdd);
> if (err)
> break;
> } else {
> /*
> * Insert lowest layer entries before upper ones, this
> * allows offsets to be reasonably constant
> */
> list_add(&rdd.middle, rdd.list);
> rdd.is_lowest = true;
> err = ovl_dir_read(&realpath, &rdd);
> list_del(&rdd.middle);
> }
> }
>
>
> rdd.middle is populated inside ovl_fill_lowest() which is indirectly invoked
> by the call to ovl_dir_read() inside the "else" part of the above "if"
> condition. Before this invocation of ovl_dir_read(), rdd.middle would
> basically be an empty list. So this would mean that the call
> list_add(&rdd.middle, rdd.list) is unnecessary.
>
> Please let me know if I am missing something here.
>
You are missing the fact that rdd.middle is not a new list.
its a list element inserted into the circular list rdd.list as a marker
to the head of the non-lowest entries list.
When referencing &rdd.middle inside ovl_fill_lowest() code
is referencing the same list that was populated in rdd.list,
but with a different head/tail.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: ovl_dir_read_merged: Redundant call to list_add()
2017-05-30 8:05 ` Amir Goldstein
@ 2017-05-30 8:47 ` Chandan Rajendra
0 siblings, 0 replies; 3+ messages in thread
From: Chandan Rajendra @ 2017-05-30 8:47 UTC (permalink / raw)
To: Amir Goldstein; +Cc: linux-unionfs@vger.kernel.org
On Tuesday, May 30, 2017 1:35:55 PM IST Amir Goldstein wrote:
> On Tue, May 30, 2017 at 9:39 AM, Chandan Rajendra
> <chandan@linux.vnet.ibm.com> wrote:
> > ovl_dir_read_merged() has the following loop,
> >
> > for (idx = 0; idx != -1; idx = next) {
> > next = ovl_path_next(idx, dentry, &realpath);
> >
> > if (next != -1) {
> > err = ovl_dir_read(&realpath, &rdd);
> > if (err)
> > break;
> > } else {
> > /*
> > * Insert lowest layer entries before upper ones, this
> > * allows offsets to be reasonably constant
> > */
> > list_add(&rdd.middle, rdd.list);
> > rdd.is_lowest = true;
> > err = ovl_dir_read(&realpath, &rdd);
> > list_del(&rdd.middle);
> > }
> > }
> >
> >
> > rdd.middle is populated inside ovl_fill_lowest() which is indirectly invoked
> > by the call to ovl_dir_read() inside the "else" part of the above "if"
> > condition. Before this invocation of ovl_dir_read(), rdd.middle would
> > basically be an empty list. So this would mean that the call
> > list_add(&rdd.middle, rdd.list) is unnecessary.
> >
> > Please let me know if I am missing something here.
> >
>
> You are missing the fact that rdd.middle is not a new list.
> its a list element inserted into the circular list rdd.list as a marker
> to the head of the non-lowest entries list.
> When referencing &rdd.middle inside ovl_fill_lowest() code
> is referencing the same list that was populated in rdd.list,
> but with a different head/tail.
>
>
Amir, Thanks for your clarification.
--
chandan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-30 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30 6:39 ovl_dir_read_merged: Redundant call to list_add() Chandan Rajendra
2017-05-30 8:05 ` Amir Goldstein
2017-05-30 8:47 ` Chandan Rajendra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox