All of lore.kernel.org
 help / color / mirror / Atom feed
* Need some help regarding write_begin, write_end and writepage(s).
@ 2016-12-28 10:03 Pranay Srivastava
  2016-12-29  7:05 ` Fwd: " Pranay Srivastava
  0 siblings, 1 reply; 3+ messages in thread
From: Pranay Srivastava @ 2016-12-28 10:03 UTC (permalink / raw)
  To: linux-fsdevel

Hello,

I'm trying to understand the write_begin, write_end and writepages /
writepage call
sequence by having a small file system coded myself.

I'm not using block_write_begin / block_write_end also not using
mpage_writepages
as well.

The issue however is that apart from write_begin and write_end, writepages never
gets called. However if I do write_inode_now ( in write_end) then writepage do
get called, but that's not how it's supposed to be.

1. in write_begin : I'm able to grab_cache_page_begin and returned it locked.

2. in write_end: I'm able to allocate disk space and do SetPageDirty
and SetPageUptodate
    unlock_page and page_cache_release.

3. I also tried __mark_inode_dirty(inode, I_DIRTY_PAGES)

4. I also tried to set_page_writeback, but apparently that then makes
the iput_final stuck since
   it waits for PG_Writeback to be cleared and that I've coded in
writepage which never
   gets called.

but writepages never gets called.

Even iput_final doesn't make the write_inode_now call.

 Any help would be appreciated.

Regards,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Fwd: Need some help regarding write_begin, write_end and writepage(s).
  2016-12-28 10:03 Need some help regarding write_begin, write_end and writepage(s) Pranay Srivastava
@ 2016-12-29  7:05 ` Pranay Srivastava
       [not found]   ` <102048.1483471700@turing-police.cc.vt.edu>
  0 siblings, 1 reply; 3+ messages in thread
From: Pranay Srivastava @ 2016-12-29  7:05 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I'm trying to understand the write_begin, write_end and writepages /
writepage call
sequence by having a small file system coded myself.

I'm not using block_write_begin / block_write_end also not using
mpage_writepages
as well.

The issue however is that apart from write_begin and write_end, writepages never
gets called. However if I do write_inode_now ( in write_end) then writepage do
get called, but that's not how it's supposed to be.

1. in write_begin : I'm able to grab_cache_page_begin and returned it locked.

2. in write_end: I'm able to allocate disk space and do SetPageDirty
and SetPageUptodate
    unlock_page and page_cache_release.

3. I also tried __mark_inode_dirty(inode, I_DIRTY_PAGES)

4. I also tried to set_page_writeback, but apparently that then makes
the iput_final stuck since
   it waits for PG_Writeback to be cleared and that I've coded in
writepage which never
   gets called.

but writepages never gets called.

Even iput_final doesn't make the write_inode_now call.

 Any help would be appreciated.

Regards,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Fwd: Need some help regarding write_begin, write_end and writepage(s).
       [not found]   ` <102048.1483471700@turing-police.cc.vt.edu>
@ 2017-01-04  6:33     ` Pranay Srivastava
  0 siblings, 0 replies; 3+ messages in thread
From: Pranay Srivastava @ 2017-01-04  6:33 UTC (permalink / raw)
  To: kernelnewbies

Hi Valdis,


On Wed, Jan 4, 2017 at 12:58 AM,  <Valdis.Kletnieks@vt.edu> wrote:
> On Thu, 29 Dec 2016 12:35:52 +0530, Pranay Srivastava said:
>> Hello,
>>
>> I'm trying to understand the write_begin, write_end and writepages /
>> writepage call
>> sequence by having a small file system coded myself.
>>
>> I'm not using block_write_begin / block_write_end also not using
>> mpage_writepages
>> as well.
>>
>> The issue however is that apart from write_begin and write_end, writepages never
>> gets called.
>
> writepages name implies that it's the API for writing multiple blocks in one call.
> Does your filesystem understand how to issue multi-block requests?  Did you

It's not about submitting batch request here. The issue I'm facing is
that even after
calling

set_page_dirty [ with aops->set_page_dirty = __set_page_dirty_nobuffers]

and doing

__mark_inode_dirty(inode, I_DIRTY_PAGES | I_DIRTY)

I was hoping that with an iput_final call, write_inode_now would be called which
would trigger my writepage. But that doesn't happen.

>From my understanding of iput_final, the writeout won't happen unless
the file system
is being unmounted[Correct?]  [ A check of MS_ACTIVE].

But that would work only for the root inode,as when the file is closed
[ say only 1 process has opened that file] so iput_final on that file's
inode won't call write_inode_now since file system is mounted [Correct?]

So now in order to trigger writepage, I have to make a call to
write_inode_now with
sync parameter as 0. So what I see now is

1.  A write of say 1 MB is to be done.
2.  generic_perform_write is called and it calls write_begin and
write_end for each page.
3. My write_end has actually become synchronous write instead of a
buffered one so each page actually
    is written out at write_end [ due to a call to write_inode_now in write_end]

I was kind of hoping for somehow to batch these writes[ 1 page at a
time] but on iput_final.

Oh 1 more thing, in generic_write_iter, there's a call to fsync and
this call never comes to my file system!
I'm pretty sure I'm missing some dirty flags somewhere but it's not
fallen in place currently.

Thanks for your reply though. I really appreciate it.

> *test* with userspace calls that *should* generate multi-block requests?
 A large write buffer > PAGE_SIZE ought to do it right?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-04  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 10:03 Need some help regarding write_begin, write_end and writepage(s) Pranay Srivastava
2016-12-29  7:05 ` Fwd: " Pranay Srivastava
     [not found]   ` <102048.1483471700@turing-police.cc.vt.edu>
2017-01-04  6:33     ` Pranay Srivastava

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.