Skip to content

Commit 5ceabb6

Browse files
committed
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "Assorted stuff pile - no common topic here" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: whack-a-mole: don't open-code iminor/imajor 9p: fix misuse of sscanf() in v9fs_stat2inode() audit_alloc_mark(): don't open-code ERR_CAST() fs/inode.c: make inode_init_always() initialize i_ino to 0 vfs: don't unnecessarily clone write access for writable fds
2 parents 580cd77 + 6f24784 commit 5ceabb6

File tree

14 files changed

+53
-65
lines changed

14 files changed

+53
-65
lines changed

Documentation/filesystems/porting.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,3 +883,10 @@ For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but
883883
uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and
884884
page references stay until I/O has completed, i.e. until ->ki_complete() has
885885
been called or returned with non -EIOCBQUEUED code.
886+
887+
---
888+
889+
**mandatory**
890+
891+
mnt_want_write_file() can now only be paired with mnt_drop_write_file(),
892+
whereas previously it could be paired with mnt_drop_write() as well.

arch/sh/boards/mach-landisk/gio.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ static int openCnt;
2727

2828
static int gio_open(struct inode *inode, struct file *filp)
2929
{
30-
int minor;
30+
int minor = iminor(inode);
3131
int ret = -ENOENT;
3232

3333
preempt_disable();
34-
minor = MINOR(inode->i_rdev);
3534
if (minor < DEVCOUNT) {
3635
if (openCnt > 0) {
3736
ret = -EALREADY;
@@ -46,9 +45,8 @@ static int gio_open(struct inode *inode, struct file *filp)
4645

4746
static int gio_close(struct inode *inode, struct file *filp)
4847
{
49-
int minor;
48+
int minor = iminor(inode);
5049

51-
minor = MINOR(inode->i_rdev);
5250
if (minor < DEVCOUNT) {
5351
openCnt--;
5452
}

drivers/block/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static inline int is_loop_device(struct file *file)
663663
{
664664
struct inode *i = file->f_mapping->host;
665665

666-
return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
666+
return i && S_ISBLK(i->i_mode) && imajor(i) == LOOP_MAJOR;
667667
}
668668

669669
static int loop_validate_file(struct file *file, struct block_device *bdev)

drivers/dax/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static void dax_free_inode(struct inode *inode)
480480
kfree(dax_dev->host);
481481
dax_dev->host = NULL;
482482
if (inode->i_rdev)
483-
ida_simple_remove(&dax_minor_ida, MINOR(inode->i_rdev));
483+
ida_simple_remove(&dax_minor_ida, iminor(inode));
484484
kmem_cache_free(dax_cache, dax_dev);
485485
}
486486

drivers/rtc/rtc-m41t80.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
785785
*/
786786
static int wdt_open(struct inode *inode, struct file *file)
787787
{
788-
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
788+
if (iminor(inode) == WATCHDOG_MINOR) {
789789
mutex_lock(&m41t80_rtc_mutex);
790790
if (test_and_set_bit(0, &wdt_is_open)) {
791791
mutex_unlock(&m41t80_rtc_mutex);
@@ -809,7 +809,7 @@ static int wdt_open(struct inode *inode, struct file *file)
809809
*/
810810
static int wdt_release(struct inode *inode, struct file *file)
811811
{
812-
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR)
812+
if (iminor(inode) == WATCHDOG_MINOR)
813813
clear_bit(0, &wdt_is_open);
814814
return 0;
815815
}

drivers/s390/char/vmur.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static int ur_open(struct inode *inode, struct file *file)
681681
* We treat the minor number as the devno of the ur device
682682
* to find in the driver tree.
683683
*/
684-
devno = MINOR(file_inode(file)->i_rdev);
684+
devno = iminor(file_inode(file));
685685

686686
urd = urdev_get_from_devno(devno);
687687
if (!urd) {

drivers/staging/vme/devices/vme_user.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
175175
static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
176176
loff_t *ppos)
177177
{
178-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
178+
unsigned int minor = iminor(file_inode(file));
179179
ssize_t retval;
180180
size_t image_size;
181181

@@ -218,7 +218,7 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
218218
static ssize_t vme_user_write(struct file *file, const char __user *buf,
219219
size_t count, loff_t *ppos)
220220
{
221-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
221+
unsigned int minor = iminor(file_inode(file));
222222
ssize_t retval;
223223
size_t image_size;
224224

@@ -260,7 +260,7 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
260260

261261
static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
262262
{
263-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
263+
unsigned int minor = iminor(file_inode(file));
264264
size_t image_size;
265265
loff_t res;
266266

@@ -294,7 +294,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
294294
struct vme_slave slave;
295295
struct vme_irq_id irq_req;
296296
unsigned long copied;
297-
unsigned int minor = MINOR(inode->i_rdev);
297+
unsigned int minor = iminor(inode);
298298
int retval;
299299
dma_addr_t pci_addr;
300300
void __user *argp = (void __user *)arg;
@@ -412,7 +412,7 @@ vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
412412
{
413413
int ret;
414414
struct inode *inode = file_inode(file);
415-
unsigned int minor = MINOR(inode->i_rdev);
415+
unsigned int minor = iminor(inode);
416416

417417
mutex_lock(&image[minor].mutex);
418418
ret = vme_user_ioctl(inode, file, cmd, arg);
@@ -481,7 +481,7 @@ static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
481481

482482
static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
483483
{
484-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
484+
unsigned int minor = iminor(file_inode(file));
485485

486486
if (type[minor] == MASTER_MINOR)
487487
return vme_user_master_mmap(minor, vma);

fs/9p/vfs_inode.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,6 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
11391139
struct super_block *sb, unsigned int flags)
11401140
{
11411141
umode_t mode;
1142-
char ext[32];
1143-
char tag_name[14];
1144-
unsigned int i_nlink;
11451142
struct v9fs_session_info *v9ses = sb->s_fs_info;
11461143
struct v9fs_inode *v9inode = V9FS_I(inode);
11471144

@@ -1159,18 +1156,18 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
11591156
inode->i_gid = stat->n_gid;
11601157
}
11611158
if ((S_ISREG(inode->i_mode)) || (S_ISDIR(inode->i_mode))) {
1162-
if (v9fs_proto_dotu(v9ses) && (stat->extension[0] != '\0')) {
1159+
if (v9fs_proto_dotu(v9ses)) {
1160+
unsigned int i_nlink;
11631161
/*
1164-
* Hadlink support got added later to
1165-
* to the .u extension. So there can be
1166-
* server out there that doesn't support
1167-
* this even with .u extension. So check
1168-
* for non NULL stat->extension
1162+
* Hadlink support got added later to the .u extension.
1163+
* So there can be a server out there that doesn't
1164+
* support this even with .u extension. That would
1165+
* just leave us with stat->extension being an empty
1166+
* string, though.
11691167
*/
1170-
strlcpy(ext, stat->extension, sizeof(ext));
11711168
/* HARDLINKCOUNT %u */
1172-
sscanf(ext, "%13s %u", tag_name, &i_nlink);
1173-
if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
1169+
if (sscanf(stat->extension,
1170+
" HARDLINKCOUNT %u", &i_nlink) == 1)
11741171
set_nlink(inode, i_nlink);
11751172
}
11761173
}

fs/gfs2/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_inode *ip,
491491
di = (struct gfs2_dinode *)dibh->b_data;
492492
gfs2_dinode_out(ip, di);
493493

494-
di->di_major = cpu_to_be32(MAJOR(ip->i_inode.i_rdev));
495-
di->di_minor = cpu_to_be32(MINOR(ip->i_inode.i_rdev));
494+
di->di_major = cpu_to_be32(imajor(&ip->i_inode));
495+
di->di_minor = cpu_to_be32(iminor(&ip->i_inode));
496496
di->__pad1 = 0;
497497
di->__pad2 = 0;
498498
di->__pad3 = 0;

fs/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
142142
atomic_set(&inode->i_count, 1);
143143
inode->i_op = &empty_iops;
144144
inode->i_fop = &no_open_fops;
145+
inode->i_ino = 0;
145146
inode->__i_nlink = 1;
146147
inode->i_opflags = 0;
147148
if (sb->s_xattr)

0 commit comments

Comments
 (0)