public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* lseek() on debugfs entries in 2.6.37
@ 2011-03-15 12:54 Alexey Mikhailov
  2011-03-15 14:01 ` Arnd Bergmann
  2011-03-15 19:36 ` Steven Rostedt
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Mikhailov @ 2011-03-15 12:54 UTC (permalink / raw)
  To: linux-kernel

Hello!

I use simple debugfs entries for user-space <-> kernel-space
interaction. Basically I read unsigned integers from debugfs
files like this:

   ...
   char buf[64];
   lseek(timesync_fd, 0, SEEK_SET);
   read(timesync_fd, buf, sizeof(buf));
   ...

It works perfectly with 2.6.32 kernel. But with 2.6.37 kernel,
lseek() fails with errno=29(Illegal seek). So second read()
call just fails or returns garbage. Can someone please shed
some light on it?

Thank you,
-- Alexey.

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

* Re: lseek() on debugfs entries in 2.6.37
  2011-03-15 12:54 lseek() on debugfs entries in 2.6.37 Alexey Mikhailov
@ 2011-03-15 14:01 ` Arnd Bergmann
  2011-03-16 10:49   ` Alexey Mikhailov
  2011-03-15 19:36 ` Steven Rostedt
  1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2011-03-15 14:01 UTC (permalink / raw)
  To: Alexey Mikhailov; +Cc: linux-kernel

On Tuesday 15 March 2011, Alexey Mikhailov wrote:
> I use simple debugfs entries for user-space <-> kernel-space
> interaction. Basically I read unsigned integers from debugfs
> files like this:
> 
>    ...
>    char buf[64];
>    lseek(timesync_fd, 0, SEEK_SET);
>    read(timesync_fd, buf, sizeof(buf));
>    ...
> 
> It works perfectly with 2.6.32 kernel. But with 2.6.37 kernel,
> lseek() fails with errno=29(Illegal seek). So second read()
> call just fails or returns garbage. Can someone please shed
> some light on it?

This is probably a result of the changes I made as part of the
BKL removal. Which file specifically are you talking about?

In older kernels, having no .llseek function meant that you
implicitly get default_llseek. New kernels now require 
that the driver explicitly chooses one llseek variant.

I did a patch to automatically convert all drivers, but
this patch may have missed some that got moved around
while I was patching them.

	Arnd

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

* Re: lseek() on debugfs entries in 2.6.37
  2011-03-15 12:54 lseek() on debugfs entries in 2.6.37 Alexey Mikhailov
  2011-03-15 14:01 ` Arnd Bergmann
@ 2011-03-15 19:36 ` Steven Rostedt
  1 sibling, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2011-03-15 19:36 UTC (permalink / raw)
  To: Alexey Mikhailov; +Cc: linux-kernel

On Tue, Mar 15, 2011 at 03:54:14PM +0300, Alexey Mikhailov wrote:
> Hello!
> 
> I use simple debugfs entries for user-space <-> kernel-space
> interaction. Basically I read unsigned integers from debugfs
> files like this:

What debugfs file? Is this something you created?

> 
>    ...
>    char buf[64];
>    lseek(timesync_fd, 0, SEEK_SET);
>    read(timesync_fd, buf, sizeof(buf));
>    ...
> 
> It works perfectly with 2.6.32 kernel. But with 2.6.37 kernel,
> lseek() fails with errno=29(Illegal seek). So second read()
> call just fails or returns garbage. Can someone please shed
> some light on it?
> 

There's been a lot of clean ups in the debugfs to patch lseek in files
that just didn't support it. Could be one of the files that got the
clean up. The lseek may have failed silently before, but now it
produceses an error.

-- Steve


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

* Re: lseek() on debugfs entries in 2.6.37
  2011-03-15 14:01 ` Arnd Bergmann
@ 2011-03-16 10:49   ` Alexey Mikhailov
  2011-03-16 11:41     ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Mikhailov @ 2011-03-16 10:49 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, Steven Rostedt

At Tue, 15 Mar 2011 15:01:41 +0100, Arnd Bergmann wrote:
Hello!

> 
> On Tuesday 15 March 2011, Alexey Mikhailov wrote:
> > I use simple debugfs entries for user-space <-> kernel-space
> > interaction. Basically I read unsigned integers from debugfs
> > files like this:
> > 
> >    ...
> >    char buf[64];
> >    lseek(timesync_fd, 0, SEEK_SET);
> >    read(timesync_fd, buf, sizeof(buf));
> >    ...
> > 
> > It works perfectly with 2.6.32 kernel. But with 2.6.37 kernel,
> > lseek() fails with errno=29(Illegal seek). So second read()
> > call just fails or returns garbage. Can someone please shed
> > some light on it?
> 
> This is probably a result of the changes I made as part of the
> BKL removal. Which file specifically are you talking about?
> 
> In older kernels, having no .llseek function meant that you
> implicitly get default_llseek. New kernels now require 
> that the driver explicitly chooses one llseek variant.

Thank you for reply. Obvious patches like this one fixed it

   static struct file_operations fops_timesync = {
      .owner = THIS_MODULE,
      .open = fop_open_timesync,
      .read = fop_read_timesync,
  +   .llseek = default_llseek,
   };

I assume there is the reason you need to specify this
explicitly as it will break much out-of-kernel code.

-- Alexey




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

* Re: lseek() on debugfs entries in 2.6.37
  2011-03-16 10:49   ` Alexey Mikhailov
@ 2011-03-16 11:41     ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2011-03-16 11:41 UTC (permalink / raw)
  To: Alexey Mikhailov; +Cc: linux-kernel, Steven Rostedt

On Wednesday 16 March 2011, Alexey Mikhailov wrote:
> Thank you for reply. Obvious patches like this one fixed it
> 
>    static struct file_operations fops_timesync = {
>       .owner = THIS_MODULE,
>       .open = fop_open_timesync,
>       .read = fop_read_timesync,
>   +   .llseek = default_llseek,
>    };
> 
> I assume there is the reason you need to specify this
> explicitly as it will break much out-of-kernel code.

Yes, this was required as a prerequisite to removing the big
kernel lock. Generally speaking, there is very little care taken
to prevent out of tree modules from breaking. If you have device
drivers that you care about, I recommend submitting them for
inclusion in drivers/staging or as a proper driver in the mainline
kernel.

	Arnd

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

end of thread, other threads:[~2011-03-16 11:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-15 12:54 lseek() on debugfs entries in 2.6.37 Alexey Mikhailov
2011-03-15 14:01 ` Arnd Bergmann
2011-03-16 10:49   ` Alexey Mikhailov
2011-03-16 11:41     ` Arnd Bergmann
2011-03-15 19:36 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox