stream_open related patches for Linux 5.2

https://lore.kernel.org/linux-fsdevel/CAHk-=wg1tFzcaX2v9Z91vPJiBR486ddW5MtgDL02-fOen2F0Aw@mail.gmail.com/T/#m5b2d9ad3aeacea4bd6aa1964468ac074bf3aa5bf
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEECVWwJCUO7/z+QjZbZsp4hBP2dUkFAlzR1UgQHGtpcnJAbmV4
 ZWRpLmNvbQAKCRBmyniEE/Z1SZBiEACGw1LzUmjV9eBYFjqaUkgX/Zfcu42D4Ek2
 8MuWnNdRabtpGQq0LccYlfoL3yH5xECp14IkCgJvkjqoZ3CcqWcv6uDxf0WtnUqZ
 wPx1RYZykb4RZj2A6/ndhInReP4AlXICyTVulKb+BquVkemMvmXX8k+bkr/msKfT
 9jdKWFIn+ANNABt3y2D7ywZvs9mkxIx+Fti+tVV4BFBeGfUuj4ArZBOHnngRnIk/
 XYlQ7FVzENSPSB+3GvL34jTGEzo8suPHKhHQlIhtcd5hwzVRZKE2sdVXsCc6/WbY
 YnT32gmT1/+cUuDl1mZSiQY5R4Xkb07k6/jNrdmjQpwmWbZu90cuRhb+JBXwnmjZ
 2Wgy3sfwYISDxtePukg1iYePlHlVlGTYqMo3AQrTBs/gEwCKWrsKQb98mRxlf1YK
 e2mdtmq6upYoorLFQesfRgrCg4GTBiPkrR3amXsFgJ2O5fhV6R98ZdGSv4kip19f
 ZNoc/t1EtKGwyAJwjINduv36E3RSHODWwSPtSnmSS1ieCGToY1SI3bVUkFM4C0tO
 5GMdSugHgXRGGVbTd/VftndJm6Wtj8b1j8c/1Vh04Q8qbKKJDRTDzAbK1v8oLaDh
 UXAKMIc8uY4caZy3/bTAB2Ou9dibrSi8Oc+LwZqJlwIcbkwn/IGNvmwtWv4ehorE
 N7EhCFZsFQ==
 =Mavg
 -----END PGP SIGNATURE-----

Merge tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux

Pull stream_open conversion from Kirill Smelkov:

 - remove unnecessary double nonseekable_open from drivers/char/dtlk.c
   as noticed by Pavel Machek while reviewing nonseekable_open ->
   stream_open mass conversion.

 - the mass conversion patch promised in commit 10dce8af34 ("fs:
   stream_open - opener for stream-like files so that read and write can
   run simultaneously without deadlock") and is automatically generated
   by running

        $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci

   I've verified each generated change manually - that it is correct to
   convert - and each other nonseekable_open instance left - that it is
   either not correct to convert there, or that it is not converted due
   to current stream_open.cocci limitations. More details on this in the
   patch.

 - finally, change VFS to pass ppos=NULL into .read/.write for files
   that declare themselves streams. It was suggested by Rasmus Villemoes
   and makes sure that if ppos starts to be erroneously used in a stream
   file, such bug won't go unnoticed and will produce an oops instead of
   creating illusion of position change being taken into account.

   Note: this patch does not conflict with "fuse: Add FOPEN_STREAM to
   use stream_open()" that will be hopefully coming via FUSE tree,
   because fs/fuse/ uses new-style .read_iter/.write_iter, and for these
   accessors position is still passed as non-pointer kiocb.ki_pos .

* tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux:
  vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files
  *: convert stream-like files from nonseekable_open -> stream_open
  dtlk: remove double call to nonseekable_open
This commit is contained in:
Linus Torvalds 2019-05-07 12:15:13 -07:00
commit 41bc10cabe
105 changed files with 179 additions and 158 deletions

View file

@ -200,7 +200,7 @@ static int acq_open(struct inode *inode, struct file *file)
/* Activate */
acq_keepalive();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int acq_close(struct inode *inode, struct file *file)

View file

@ -199,7 +199,7 @@ static int advwdt_open(struct inode *inode, struct file *file)
*/
advwdt_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int advwdt_close(struct inode *inode, struct file *file)

View file

@ -249,7 +249,7 @@ static int ali_open(struct inode *inode, struct file *file)
/* Activate */
ali_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/*

View file

@ -214,7 +214,7 @@ static int fop_open(struct inode *inode, struct file *file)
return -EBUSY;
/* Good, fire up the show */
wdt_startup();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int fop_close(struct inode *inode, struct file *file)

View file

@ -163,7 +163,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file)
ar7_wdt_enable_wdt();
expect_close = 0;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int ar7_wdt_release(struct inode *inode, struct file *file)

View file

@ -110,7 +110,7 @@ static int at91_wdt_open(struct inode *inode, struct file *file)
return -EBUSY;
at91_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/*

View file

@ -132,7 +132,7 @@ static int ath79_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
ath79_wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int ath79_wdt_release(struct inode *inode, struct file *file)

View file

@ -116,7 +116,7 @@ static int bcm63xx_wdt_open(struct inode *inode, struct file *file)
return -EBUSY;
bcm63xx_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int bcm63xx_wdt_release(struct inode *inode, struct file *file)

View file

@ -140,7 +140,7 @@ static int cpu5wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(0, &cpu5wdt_device.inuse))
return -EBUSY;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int cpu5wdt_release(struct inode *inode, struct file *file)

View file

@ -394,7 +394,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
mutex_unlock(&cpwd_mutex);
return nonseekable_open(inode, f);
return stream_open(inode, f);
}
static int cpwd_release(struct inode *inode, struct file *file)

View file

@ -316,7 +316,7 @@ static int eurwdt_open(struct inode *inode, struct file *file)
eurwdt_timeout = WDT_TIMEOUT; /* initial timeout */
/* Activate the WDT */
eurwdt_activate_timer();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**

View file

@ -525,7 +525,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
watchdog.expect_close = 0;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int watchdog_release(struct inode *inode, struct file *file)

View file

@ -229,7 +229,7 @@ static int gef_wdt_open(struct inode *inode, struct file *file)
gef_wdt_handler_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int gef_wdt_release(struct inode *inode, struct file *file)

View file

@ -92,7 +92,7 @@ static int geodewdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
geodewdt_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int geodewdt_release(struct inode *inode, struct file *file)

View file

@ -238,7 +238,7 @@ static int ibwdt_open(struct inode *inode, struct file *file)
/* Activate */
ibwdt_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int ibwdt_close(struct inode *inode, struct file *file)

View file

@ -323,7 +323,7 @@ static int asr_open(struct inode *inode, struct file *file)
asr_toggle();
asr_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int asr_release(struct inode *inode, struct file *file)

View file

@ -77,7 +77,7 @@ static int indydog_open(struct inode *inode, struct file *file)
pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int indydog_release(struct inode *inode, struct file *file)

View file

@ -304,7 +304,7 @@ static int intel_scu_open(struct inode *inode, struct file *file)
if (watchdog_device.driver_closed)
return -EPERM;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int intel_scu_release(struct inode *inode, struct file *file)

View file

@ -101,7 +101,7 @@ static int iop_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable();
set_bit(WDT_ENABLED, &wdt_status);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static ssize_t iop_wdt_write(struct file *file, const char *data, size_t len,

View file

@ -327,7 +327,7 @@ static int it8712f_wdt_open(struct inode *inode, struct file *file)
ret = it8712f_wdt_enable();
if (ret)
return ret;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int it8712f_wdt_release(struct inode *inode, struct file *file)

View file

@ -65,7 +65,7 @@ static int ixp4xx_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static ssize_t

View file

@ -142,7 +142,7 @@ static int ks8695_wdt_open(struct inode *inode, struct file *file)
return -EBUSY;
ks8695_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/*

View file

@ -85,7 +85,7 @@ static int m54xx_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static ssize_t m54xx_wdt_write(struct file *file, const char *data,

View file

@ -333,7 +333,7 @@ static int zf_open(struct inode *inode, struct file *file)
if (nowayout)
__module_get(THIS_MODULE);
zf_timer_on();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int zf_close(struct inode *inode, struct file *file)

View file

@ -150,7 +150,7 @@ static int mixcomwd_open(struct inode *inode, struct file *file)
mixcomwd_timer_alive = 0;
}
}
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int mixcomwd_release(struct inode *inode, struct file *file)

View file

@ -118,7 +118,7 @@ static int mtx1_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(0, &mtx1_wdt_device.inuse))
return -EBUSY;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

View file

@ -133,7 +133,7 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file)
mv64x60_wdt_handler_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int mv64x60_wdt_release(struct inode *inode, struct file *file)

View file

@ -131,7 +131,7 @@ static int nuc900_wdt_open(struct inode *inode, struct file *file)
nuc900_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int nuc900_wdt_close(struct inode *inode, struct file *file)

View file

@ -161,7 +161,7 @@ static int nv_tco_open(struct inode *inode, struct file *file)
/* Reload and activate timer */
tco_timer_keepalive();
tco_timer_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int nv_tco_release(struct inode *inode, struct file *file)

View file

@ -286,7 +286,7 @@ static int pc87413_open(struct inode *inode, struct file *file)
pr_info("Watchdog enabled. Timeout set to %d minute(s).\n", timeout);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**

View file

@ -695,7 +695,7 @@ static int pcwd_open(struct inode *inode, struct file *file)
/* Activate */
pcwd_start();
pcwd_keepalive();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int pcwd_close(struct inode *inode, struct file *file)
@ -734,7 +734,7 @@ static int pcwd_temp_open(struct inode *inode, struct file *file)
if (!pcwd_private.supports_temp)
return -ENODEV;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int pcwd_temp_close(struct inode *inode, struct file *file)

View file

@ -578,7 +578,7 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
/* Activate */
pcipcwd_start();
pcipcwd_keepalive();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int pcipcwd_release(struct inode *inode, struct file *file)
@ -620,7 +620,7 @@ static int pcipcwd_temp_open(struct inode *inode, struct file *file)
if (!pcipcwd_private.supports_temp)
return -ENODEV;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int pcipcwd_temp_release(struct inode *inode, struct file *file)

View file

@ -485,7 +485,7 @@ static int usb_pcwd_open(struct inode *inode, struct file *file)
/* Activate */
usb_pcwd_start(usb_pcwd_device);
usb_pcwd_keepalive(usb_pcwd_device);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int usb_pcwd_release(struct inode *inode, struct file *file)
@ -524,7 +524,7 @@ static ssize_t usb_pcwd_temperature_read(struct file *file, char __user *data,
static int usb_pcwd_temperature_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)

View file

@ -118,7 +118,7 @@ static int pikawdt_open(struct inode *inode, struct file *file)
pikawdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/*

View file

@ -116,7 +116,7 @@ static int pnx833x_wdt_open(struct inode *inode, struct file *file)
pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int pnx833x_wdt_release(struct inode *inode, struct file *file)

View file

@ -150,7 +150,7 @@ static int rc32434_wdt_open(struct inode *inode, struct file *file)
rc32434_wdt_start();
rc32434_wdt_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int rc32434_wdt_release(struct inode *inode, struct file *file)

View file

@ -142,7 +142,7 @@ static int rdc321x_wdt_open(struct inode *inode, struct file *file)
if (test_and_set_bit(0, &rdc321x_wdt_device.inuse))
return -EBUSY;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int rdc321x_wdt_release(struct inode *inode, struct file *file)

View file

@ -76,7 +76,7 @@ static void riowd_writereg(struct riowd *p, u8 val, int index)
static int riowd_open(struct inode *inode, struct file *filp)
{
nonseekable_open(inode, filp);
stream_open(inode, filp);
return 0;
}

View file

@ -59,7 +59,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
writel_relaxed(OSSR_M3, OSSR);
writel_relaxed(OWER_WME, OWER);
writel_relaxed(readl_relaxed(OIER) | OIER_E3, OIER);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/*

View file

@ -105,7 +105,7 @@ static const struct watchdog_info ident = {
*/
static int sbwdog_open(struct inode *inode, struct file *file)
{
nonseekable_open(inode, file);
stream_open(inode, file);
if (test_and_set_bit(0, &sbwdog_gate))
return -EBUSY;
__module_get(THIS_MODULE);

View file

@ -208,7 +208,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */
wdt_startup();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int fop_close(struct inode *inode, struct file *file)

View file

@ -136,7 +136,7 @@ static int fop_open(struct inode *inode, struct file *file)
wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int fop_close(struct inode *inode, struct file *file)

View file

@ -271,7 +271,7 @@ static int sbc8360_open(struct inode *inode, struct file *file)
/* Activate and ping once to start the countdown */
sbc8360_activate();
sbc8360_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int sbc8360_close(struct inode *inode, struct file *file)

View file

@ -78,7 +78,7 @@ static int epx_c3_open(struct inode *inode, struct file *file)
epx_c3_alive = 1;
pr_info("Started watchdog timer\n");
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int epx_c3_release(struct inode *inode, struct file *file)

View file

@ -75,7 +75,7 @@ static int fitpc2_wdt_open(struct inode *inode, struct file *file)
wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static ssize_t fitpc2_wdt_write(struct file *file, const char *data,

View file

@ -178,7 +178,7 @@ static int sc1200wdt_open(struct inode *inode, struct file *file)
sc1200wdt_start();
pr_info("Watchdog enabled, timeout = %d min(s)", timeout);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

View file

@ -258,7 +258,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */
wdt_startup();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int fop_close(struct inode *inode, struct file *file)

View file

@ -316,7 +316,7 @@ static int sch311x_wdt_open(struct inode *inode, struct file *file)
* Activate
*/
sch311x_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int sch311x_wdt_close(struct inode *inode, struct file *file)

View file

@ -102,7 +102,7 @@ static int scx200_wdt_open(struct inode *inode, struct file *file)
return -EBUSY;
scx200_wdt_enable();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int scx200_wdt_release(struct inode *inode, struct file *file)

View file

@ -366,7 +366,7 @@ static int wb_smsc_wdt_open(struct inode *inode, struct file *file)
pr_info("Watchdog enabled. Timeout set to %d %s\n",
timeout, (unit == UNIT_SECOND) ? "second(s)" : "minute(s)");
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/* close => shut off the timer */

View file

@ -224,7 +224,7 @@ static int fop_open(struct inode *inode, struct file *file)
/* Good, fire up the show */
wdt_startup();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int fop_close(struct inode *inode, struct file *file)

View file

@ -298,7 +298,7 @@ static int wdt_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int wdt_release(struct inode *inode, struct file *file)

View file

@ -197,7 +197,7 @@ static int wafwdt_open(struct inode *inode, struct file *file)
* Activate
*/
wafwdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int wafwdt_close(struct inode *inode, struct file *file)

View file

@ -825,7 +825,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
kref_get(&wd_data->kref);
/* dev/watchdog is a virtual (and thus non-seekable) filesystem */
return nonseekable_open(inode, file);
return stream_open(inode, file);
out_mod:
module_put(wd_data->wdd->ops->owner);

View file

@ -376,7 +376,7 @@ static int wdrtas_open(struct inode *inode, struct file *file)
wdrtas_timer_start();
wdrtas_timer_keepalive();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**
@ -442,7 +442,7 @@ static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
*/
static int wdrtas_temp_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**

View file

@ -421,7 +421,7 @@ static int wdt_open(struct inode *inode, struct file *file)
* Activate
*/
wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**
@ -481,7 +481,7 @@ static ssize_t wdt_temp_read(struct file *file, char __user *buf,
static int wdt_temp_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**

View file

@ -101,7 +101,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
ret = 0;
#endif
nonseekable_open(inode, file);
stream_open(inode, file);
return ret;
}

View file

@ -273,7 +273,7 @@ static int wdt977_open(struct inode *inode, struct file *file)
__module_get(THIS_MODULE);
wdt977_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
static int wdt977_release(struct inode *inode, struct file *file)

View file

@ -461,7 +461,7 @@ static int wdtpci_open(struct inode *inode, struct file *file)
* Activate
*/
wdtpci_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**
@ -524,7 +524,7 @@ static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
static int wdtpci_temp_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
/**