Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (69 commits)
fix handling of offsets in cris eeprom.c, get rid of fake on-stack files
get rid of home-grown mutex in cris eeprom.c
switch ecryptfs_write() to struct inode *, kill on-stack fake files
switch ecryptfs_get_locked_page() to struct inode *
simplify access to ecryptfs inodes in ->readpage() and friends
AFS: Don't put struct file on the stack
Ban ecryptfs over ecryptfs
logfs: replace inode uid,gid,mode initialization with helper function
ufs: replace inode uid,gid,mode initialization with helper function
udf: replace inode uid,gid,mode init with helper
ubifs: replace inode uid,gid,mode initialization with helper function
sysv: replace inode uid,gid,mode initialization with helper function
reiserfs: replace inode uid,gid,mode initialization with helper function
ramfs: replace inode uid,gid,mode initialization with helper function
omfs: replace inode uid,gid,mode initialization with helper function
bfs: replace inode uid,gid,mode initialization with helper function
ocfs2: replace inode uid,gid,mode initialization with helper function
nilfs2: replace inode uid,gid,mode initialization with helper function
minix: replace inode uid,gid,mode init with helper
ext4: replace inode uid,gid,mode init with helper
...

Trivial conflict in fs/fs-writeback.c (mark bitfields unsigned)

+913 -1300
+15 -33
arch/cris/arch-v10/drivers/eeprom.c
··· 73 73 int adapt_state; /* 1 = To high , 0 = Even, -1 = To low */ 74 74 75 75 /* this one is to keep the read/write operations atomic */ 76 - wait_queue_head_t wait_q; 77 - volatile int busy; 76 + struct mutex lock; 78 77 int retry_cnt_addr; /* Used to keep track of number of retries for 79 78 adaptive timing adjustments */ 80 79 int retry_cnt_read; ··· 114 115 115 116 int __init eeprom_init(void) 116 117 { 117 - init_waitqueue_head(&eeprom.wait_q); 118 - eeprom.busy = 0; 118 + mutex_init(&eeprom.lock); 119 119 120 120 #ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE 121 121 #define EETEXT "Found" ··· 437 439 438 440 static int eeprom_read_buf(loff_t addr, char * buf, int count) 439 441 { 440 - struct file f; 441 - 442 - f.f_pos = addr; 443 - return eeprom_read(&f, buf, count, &addr); 442 + return eeprom_read(NULL, buf, count, &addr); 444 443 } 445 444 446 445 ··· 447 452 static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off) 448 453 { 449 454 int read=0; 450 - unsigned long p = file->f_pos; 455 + unsigned long p = *off; 451 456 452 457 unsigned char page; 453 458 ··· 456 461 return -EFAULT; 457 462 } 458 463 459 - wait_event_interruptible(eeprom.wait_q, !eeprom.busy); 460 - if (signal_pending(current)) 464 + if (mutex_lock_interruptible(&eeprom.lock)) 461 465 return -EINTR; 462 - 463 - eeprom.busy++; 464 466 465 467 page = (unsigned char) (p >> 8); 466 468 ··· 468 476 i2c_stop(); 469 477 470 478 /* don't forget to wake them up */ 471 - eeprom.busy--; 472 - wake_up_interruptible(&eeprom.wait_q); 479 + mutex_unlock(&eeprom.lock); 473 480 return -EFAULT; 474 481 } 475 482 ··· 492 501 493 502 if(read > 0) 494 503 { 495 - file->f_pos += read; 504 + *off += read; 496 505 } 497 506 498 - eeprom.busy--; 499 - wake_up_interruptible(&eeprom.wait_q); 507 + mutex_unlock(&eeprom.lock); 500 508 return read; 501 509 } 502 510 ··· 503 513 504 514 static int eeprom_write_buf(loff_t addr, const char * buf, int count) 505 515 { 506 - struct file f; 507 - 508 - f.f_pos = addr; 509 - 510 - return eeprom_write(&f, buf, count, &addr); 516 + return eeprom_write(NULL, buf, count, &addr); 511 517 } 512 518 513 519 ··· 520 534 return -EFAULT; 521 535 } 522 536 523 - wait_event_interruptible(eeprom.wait_q, !eeprom.busy); 524 537 /* bail out if we get interrupted */ 525 - if (signal_pending(current)) 538 + if (mutex_lock_interruptible(&eeprom.lock)) 526 539 return -EINTR; 527 - eeprom.busy++; 528 540 for(i = 0; (i < EEPROM_RETRIES) && (restart > 0); i++) 529 541 { 530 542 restart = 0; 531 543 written = 0; 532 - p = file->f_pos; 544 + p = *off; 533 545 534 546 535 547 while( (written < count) && (p < eeprom.size)) ··· 540 556 i2c_stop(); 541 557 542 558 /* don't forget to wake them up */ 543 - eeprom.busy--; 544 - wake_up_interruptible(&eeprom.wait_q); 559 + mutex_unlock(&eeprom.lock); 545 560 return -EFAULT; 546 561 } 547 562 #ifdef EEPROM_ADAPTIVE_TIMING ··· 652 669 } /* while */ 653 670 } /* for */ 654 671 655 - eeprom.busy--; 656 - wake_up_interruptible(&eeprom.wait_q); 657 - if (written == 0 && file->f_pos >= eeprom.size){ 672 + mutex_unlock(&eeprom.lock); 673 + if (written == 0 && p >= eeprom.size){ 658 674 return -ENOSPC; 659 675 } 660 - file->f_pos += written; 676 + *off = p; 661 677 return written; 662 678 } 663 679
+2 -2
drivers/block/loop.c
··· 485 485 goto out; 486 486 } 487 487 488 - ret = vfs_fsync(file, file->f_path.dentry, 0); 488 + ret = vfs_fsync(file, 0); 489 489 if (unlikely(ret)) { 490 490 ret = -EIO; 491 491 goto out; ··· 495 495 ret = lo_send(lo, bio, pos); 496 496 497 497 if (barrier && !ret) { 498 - ret = vfs_fsync(file, file->f_path.dentry, 0); 498 + ret = vfs_fsync(file, 0); 499 499 if (unlikely(ret)) 500 500 ret = -EIO; 501 501 }
+1 -1
drivers/md/bitmap.c
··· 1699 1699 * and bypass the page cache, we must sync the file 1700 1700 * first. 1701 1701 */ 1702 - vfs_fsync(file, file->f_dentry, 1); 1702 + vfs_fsync(file, 1); 1703 1703 } 1704 1704 /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */ 1705 1705 if (!mddev->bitmap_info.external)
+1 -1
drivers/usb/gadget/storage_common.c
··· 654 654 655 655 if (curlun->ro || !filp) 656 656 return 0; 657 - return vfs_fsync(filp, filp->f_path.dentry, 1); 657 + return vfs_fsync(filp, 1); 658 658 } 659 659 660 660 static void store_cdrom_address(u8 *dest, int msf, u32 addr)
+1 -3
fs/9p/vfs_inode.c
··· 253 253 return ERR_PTR(-ENOMEM); 254 254 } 255 255 256 - inode->i_mode = mode; 257 - inode->i_uid = current_fsuid(); 258 - inode->i_gid = current_fsgid(); 256 + inode_init_owner(inode, NULL, mode); 259 257 inode->i_blocks = 0; 260 258 inode->i_rdev = 0; 261 259 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+1 -1
fs/Makefile
··· 11 11 attr.o bad_inode.o file.o filesystems.o namespace.o \ 12 12 seq_file.o xattr.o libfs.o fs-writeback.o \ 13 13 pnode.o drop_caches.o splice.o sync.o utimes.o \ 14 - stack.o fs_struct.o 14 + stack.o fs_struct.o statfs.o 15 15 16 16 ifeq ($(CONFIG_BLOCK),y) 17 17 obj-y += buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
+1 -5
fs/afs/dir.c
··· 189 189 struct key *key) 190 190 { 191 191 struct page *page; 192 - struct file file = { 193 - .private_data = key, 194 - }; 195 - 196 192 _enter("{%lu},%lu", dir->i_ino, index); 197 193 198 - page = read_mapping_page(dir->i_mapping, index, &file); 194 + page = read_cache_page(dir->i_mapping, index, afs_page_filler, key); 199 195 if (!IS_ERR(page)) { 200 196 kmap(page); 201 197 if (!PageChecked(page))
+37 -27
fs/afs/file.c
··· 121 121 #endif 122 122 123 123 /* 124 - * AFS read page from file, directory or symlink 124 + * read page from file, directory or symlink, given a key to use 125 125 */ 126 - static int afs_readpage(struct file *file, struct page *page) 126 + int afs_page_filler(void *data, struct page *page) 127 127 { 128 - struct afs_vnode *vnode; 129 - struct inode *inode; 130 - struct key *key; 128 + struct inode *inode = page->mapping->host; 129 + struct afs_vnode *vnode = AFS_FS_I(inode); 130 + struct key *key = data; 131 131 size_t len; 132 132 off_t offset; 133 133 int ret; 134 134 135 - inode = page->mapping->host; 136 - 137 - if (file) { 138 - key = file->private_data; 139 - ASSERT(key != NULL); 140 - } else { 141 - key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell); 142 - if (IS_ERR(key)) { 143 - ret = PTR_ERR(key); 144 - goto error_nokey; 145 - } 146 - } 147 - 148 135 _enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index); 149 - 150 - vnode = AFS_FS_I(inode); 151 136 152 137 BUG_ON(!PageLocked(page)); 153 138 ··· 199 214 unlock_page(page); 200 215 } 201 216 202 - if (!file) 203 - key_put(key); 204 217 _leave(" = 0"); 205 218 return 0; 206 219 207 220 error: 208 221 SetPageError(page); 209 222 unlock_page(page); 210 - if (!file) 211 - key_put(key); 212 - error_nokey: 213 223 _leave(" = %d", ret); 224 + return ret; 225 + } 226 + 227 + /* 228 + * read page from file, directory or symlink, given a file to nominate the key 229 + * to be used 230 + */ 231 + static int afs_readpage(struct file *file, struct page *page) 232 + { 233 + struct key *key; 234 + int ret; 235 + 236 + if (file) { 237 + key = file->private_data; 238 + ASSERT(key != NULL); 239 + ret = afs_page_filler(key, page); 240 + } else { 241 + struct inode *inode = page->mapping->host; 242 + key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell); 243 + if (IS_ERR(key)) { 244 + ret = PTR_ERR(key); 245 + } else { 246 + ret = afs_page_filler(key, page); 247 + key_put(key); 248 + } 249 + } 214 250 return ret; 215 251 } 216 252 ··· 241 235 static int afs_readpages(struct file *file, struct address_space *mapping, 242 236 struct list_head *pages, unsigned nr_pages) 243 237 { 238 + struct key *key = file->private_data; 244 239 struct afs_vnode *vnode; 245 240 int ret = 0; 246 241 247 - _enter(",{%lu},,%d", mapping->host->i_ino, nr_pages); 242 + _enter("{%d},{%lu},,%d", 243 + key_serial(key), mapping->host->i_ino, nr_pages); 244 + 245 + ASSERT(key != NULL); 248 246 249 247 vnode = AFS_FS_I(mapping->host); 250 248 if (vnode->flags & AFS_VNODE_DELETED) { ··· 289 279 } 290 280 291 281 /* load the missing pages from the network */ 292 - ret = read_cache_pages(mapping, pages, (void *) afs_readpage, file); 282 + ret = read_cache_pages(mapping, pages, afs_page_filler, key); 293 283 294 284 _leave(" = %d [netting]", ret); 295 285 return ret;
+1
fs/afs/internal.h
··· 494 494 495 495 extern int afs_open(struct inode *, struct file *); 496 496 extern int afs_release(struct inode *, struct file *); 497 + extern int afs_page_filler(void *, struct page *); 497 498 498 499 /* 499 500 * flock.c
+2 -4
fs/afs/mntpt.c
··· 49 49 */ 50 50 int afs_mntpt_check_symlink(struct afs_vnode *vnode, struct key *key) 51 51 { 52 - struct file file = { 53 - .private_data = key, 54 - }; 55 52 struct page *page; 56 53 size_t size; 57 54 char *buf; ··· 58 61 vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); 59 62 60 63 /* read the contents of the symlink into the pagecache */ 61 - page = read_mapping_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, &file); 64 + page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, 65 + afs_page_filler, key); 62 66 if (IS_ERR(page)) { 63 67 ret = PTR_ERR(page); 64 68 goto out;
+1 -1
fs/anon_inodes.c
··· 205 205 * that it already _is_ on the dirty list. 206 206 */ 207 207 inode->i_state = I_DIRTY; 208 - inode->i_mode = S_IRUSR | S_IWUSR; 208 + inode->i_mode = S_IFREG | S_IRUSR | S_IWUSR; 209 209 inode->i_uid = current_fsuid(); 210 210 inode->i_gid = current_fsgid(); 211 211 inode->i_flags |= S_PRIVATE;
+1 -3
fs/bfs/dir.c
··· 105 105 } 106 106 set_bit(ino, info->si_imap); 107 107 info->si_freei--; 108 - inode->i_uid = current_fsuid(); 109 - inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current_fsgid(); 108 + inode_init_owner(inode, dir, mode); 110 109 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 111 110 inode->i_blocks = 0; 112 111 inode->i_op = &bfs_file_inops; 113 112 inode->i_fop = &bfs_file_operations; 114 113 inode->i_mapping->a_ops = &bfs_aops; 115 - inode->i_mode = mode; 116 114 inode->i_ino = ino; 117 115 BFS_I(inode)->i_dsk_ino = ino; 118 116 BFS_I(inode)->i_sblock = 0;
+15 -56
fs/block_dev.c
··· 245 245 sb = get_active_super(bdev); 246 246 if (!sb) 247 247 goto out; 248 - if (sb->s_flags & MS_RDONLY) { 249 - sb->s_frozen = SB_FREEZE_TRANS; 250 - up_write(&sb->s_umount); 248 + error = freeze_super(sb); 249 + if (error) { 250 + deactivate_super(sb); 251 + bdev->bd_fsfreeze_count--; 251 252 mutex_unlock(&bdev->bd_fsfreeze_mutex); 252 - return sb; 253 + return ERR_PTR(error); 253 254 } 254 - 255 - sb->s_frozen = SB_FREEZE_WRITE; 256 - smp_wmb(); 257 - 258 - sync_filesystem(sb); 259 - 260 - sb->s_frozen = SB_FREEZE_TRANS; 261 - smp_wmb(); 262 - 263 - sync_blockdev(sb->s_bdev); 264 - 265 - if (sb->s_op->freeze_fs) { 266 - error = sb->s_op->freeze_fs(sb); 267 - if (error) { 268 - printk(KERN_ERR 269 - "VFS:Filesystem freeze failed\n"); 270 - sb->s_frozen = SB_UNFROZEN; 271 - deactivate_locked_super(sb); 272 - bdev->bd_fsfreeze_count--; 273 - mutex_unlock(&bdev->bd_fsfreeze_mutex); 274 - return ERR_PTR(error); 275 - } 276 - } 277 - up_write(&sb->s_umount); 278 - 255 + deactivate_super(sb); 279 256 out: 280 257 sync_blockdev(bdev); 281 258 mutex_unlock(&bdev->bd_fsfreeze_mutex); ··· 273 296 274 297 mutex_lock(&bdev->bd_fsfreeze_mutex); 275 298 if (!bdev->bd_fsfreeze_count) 276 - goto out_unlock; 299 + goto out; 277 300 278 301 error = 0; 279 302 if (--bdev->bd_fsfreeze_count > 0) 280 - goto out_unlock; 303 + goto out; 281 304 282 305 if (!sb) 283 - goto out_unlock; 306 + goto out; 284 307 285 - BUG_ON(sb->s_bdev != bdev); 286 - down_write(&sb->s_umount); 287 - if (sb->s_flags & MS_RDONLY) 288 - goto out_unfrozen; 289 - 290 - if (sb->s_op->unfreeze_fs) { 291 - error = sb->s_op->unfreeze_fs(sb); 292 - if (error) { 293 - printk(KERN_ERR 294 - "VFS:Filesystem thaw failed\n"); 295 - sb->s_frozen = SB_FREEZE_TRANS; 296 - bdev->bd_fsfreeze_count++; 297 - mutex_unlock(&bdev->bd_fsfreeze_mutex); 298 - return error; 299 - } 308 + error = thaw_super(sb); 309 + if (error) { 310 + bdev->bd_fsfreeze_count++; 311 + mutex_unlock(&bdev->bd_fsfreeze_mutex); 312 + return error; 300 313 } 301 - 302 - out_unfrozen: 303 - sb->s_frozen = SB_UNFROZEN; 304 - smp_wmb(); 305 - wake_up(&sb->s_wait_unfrozen); 306 - 307 - if (sb) 308 - deactivate_locked_super(sb); 309 - out_unlock: 314 + out: 310 315 mutex_unlock(&bdev->bd_fsfreeze_mutex); 311 316 return 0; 312 317 }
+2 -2
fs/btrfs/acl.c
··· 282 282 return ret; 283 283 } 284 284 285 - struct xattr_handler btrfs_xattr_acl_default_handler = { 285 + const struct xattr_handler btrfs_xattr_acl_default_handler = { 286 286 .prefix = POSIX_ACL_XATTR_DEFAULT, 287 287 .flags = ACL_TYPE_DEFAULT, 288 288 .get = btrfs_xattr_acl_get, 289 289 .set = btrfs_xattr_acl_set, 290 290 }; 291 291 292 - struct xattr_handler btrfs_xattr_acl_access_handler = { 292 + const struct xattr_handler btrfs_xattr_acl_access_handler = { 293 293 .prefix = POSIX_ACL_XATTR_ACCESS, 294 294 .flags = ACL_TYPE_ACCESS, 295 295 .get = btrfs_xattr_acl_get,
+1 -10
fs/btrfs/inode.c
··· 4121 4121 if (ret != 0) 4122 4122 goto fail; 4123 4123 4124 - inode->i_uid = current_fsuid(); 4125 - 4126 - if (dir && (dir->i_mode & S_ISGID)) { 4127 - inode->i_gid = dir->i_gid; 4128 - if (S_ISDIR(mode)) 4129 - mode |= S_ISGID; 4130 - } else 4131 - inode->i_gid = current_fsgid(); 4132 - 4133 - inode->i_mode = mode; 4124 + inode_init_owner(inode, dir, mode); 4134 4125 inode->i_ino = objectid; 4135 4126 inode_set_bytes(inode, 0); 4136 4127 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+1 -1
fs/btrfs/xattr.c
··· 282 282 * List of handlers for synthetic system.* attributes. All real ondisk 283 283 * attributes are handled directly. 284 284 */ 285 - struct xattr_handler *btrfs_xattr_handlers[] = { 285 + const struct xattr_handler *btrfs_xattr_handlers[] = { 286 286 #ifdef CONFIG_BTRFS_FS_POSIX_ACL 287 287 &btrfs_xattr_acl_access_handler, 288 288 &btrfs_xattr_acl_default_handler,
+3 -3
fs/btrfs/xattr.h
··· 21 21 22 22 #include <linux/xattr.h> 23 23 24 - extern struct xattr_handler btrfs_xattr_acl_access_handler; 25 - extern struct xattr_handler btrfs_xattr_acl_default_handler; 26 - extern struct xattr_handler *btrfs_xattr_handlers[]; 24 + extern const struct xattr_handler btrfs_xattr_acl_access_handler; 25 + extern const struct xattr_handler btrfs_xattr_acl_default_handler; 26 + extern const struct xattr_handler *btrfs_xattr_handlers[]; 27 27 28 28 extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name, 29 29 void *buffer, size_t size);
+9 -18
fs/buffer.c
··· 561 561 return err; 562 562 } 563 563 564 + static void do_thaw_one(struct super_block *sb, void *unused) 565 + { 566 + char b[BDEVNAME_SIZE]; 567 + while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb)) 568 + printk(KERN_WARNING "Emergency Thaw on %s\n", 569 + bdevname(sb->s_bdev, b)); 570 + } 571 + 564 572 static void do_thaw_all(struct work_struct *work) 565 573 { 566 - struct super_block *sb; 567 - char b[BDEVNAME_SIZE]; 568 - 569 - spin_lock(&sb_lock); 570 - restart: 571 - list_for_each_entry(sb, &super_blocks, s_list) { 572 - sb->s_count++; 573 - spin_unlock(&sb_lock); 574 - down_read(&sb->s_umount); 575 - while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb)) 576 - printk(KERN_WARNING "Emergency Thaw on %s\n", 577 - bdevname(sb->s_bdev, b)); 578 - up_read(&sb->s_umount); 579 - spin_lock(&sb_lock); 580 - if (__put_super_and_need_restart(sb)) 581 - goto restart; 582 - } 583 - spin_unlock(&sb_lock); 574 + iterate_supers(do_thaw_one, NULL); 584 575 kfree(work); 585 576 printk(KERN_WARNING "Emergency Thaw complete\n"); 586 577 }
+1 -2
fs/ceph/file.c
··· 844 844 if ((ret >= 0 || ret == -EIOCBQUEUED) && 845 845 ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host) 846 846 || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) { 847 - err = vfs_fsync_range(file, file->f_path.dentry, 848 - pos, pos + ret - 1, 1); 847 + err = vfs_fsync_range(file, pos, pos + ret - 1, 1); 849 848 if (err < 0) 850 849 ret = err; 851 850 }
+1 -2
fs/ceph/super.c
··· 952 952 953 953 out_splat: 954 954 ceph_mdsc_close_sessions(&client->mdsc); 955 - up_write(&sb->s_umount); 956 - deactivate_super(sb); 955 + deactivate_locked_super(sb); 957 956 goto out_final; 958 957 959 958 out:
+1 -1
fs/coda/file.c
··· 217 217 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 218 218 host_file = cfi->cfi_container; 219 219 220 - err = vfs_fsync(host_file, host_file->f_path.dentry, datasync); 220 + err = vfs_fsync(host_file, datasync); 221 221 if ( !err && !datasync ) { 222 222 lock_kernel(); 223 223 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
+9 -11
fs/dcache.c
··· 536 536 */ 537 537 static void prune_dcache(int count) 538 538 { 539 - struct super_block *sb; 539 + struct super_block *sb, *n; 540 540 int w_count; 541 541 int unused = dentry_stat.nr_unused; 542 542 int prune_ratio; ··· 545 545 if (unused == 0 || count == 0) 546 546 return; 547 547 spin_lock(&dcache_lock); 548 - restart: 549 548 if (count >= unused) 550 549 prune_ratio = 1; 551 550 else 552 551 prune_ratio = unused / count; 553 552 spin_lock(&sb_lock); 554 - list_for_each_entry(sb, &super_blocks, s_list) { 553 + list_for_each_entry_safe(sb, n, &super_blocks, s_list) { 554 + if (list_empty(&sb->s_instances)) 555 + continue; 555 556 if (sb->s_nr_dentry_unused == 0) 556 557 continue; 557 558 sb->s_count++; ··· 591 590 } 592 591 spin_lock(&sb_lock); 593 592 count -= pruned; 594 - /* 595 - * restart only when sb is no longer on the list and 596 - * we have more work to do. 597 - */ 598 - if (__put_super_and_need_restart(sb) && count > 0) { 599 - spin_unlock(&sb_lock); 600 - goto restart; 601 - } 593 + __put_super(sb); 594 + /* more work left to do? */ 595 + if (count <= 0) 596 + break; 602 597 } 603 598 spin_unlock(&sb_lock); 604 599 spin_unlock(&dcache_lock); ··· 1526 1529 spin_lock(&dentry->d_lock); 1527 1530 isdir = S_ISDIR(dentry->d_inode->i_mode); 1528 1531 if (atomic_read(&dentry->d_count) == 1) { 1532 + dentry->d_flags &= ~DCACHE_CANT_MOUNT; 1529 1533 dentry_iput(dentry); 1530 1534 fsnotify_nameremove(dentry, isdir); 1531 1535 return;
+3 -6
fs/devpts/inode.c
··· 384 384 s->s_flags |= MS_ACTIVE; 385 385 } 386 386 387 - simple_set_mnt(mnt, s); 388 - 389 387 memcpy(&(DEVPTS_SB(s))->mount_opts, &opts, sizeof(opts)); 390 388 391 389 error = mknod_ptmx(s); 392 390 if (error) 393 - goto out_dput; 391 + goto out_undo_sget; 392 + 393 + simple_set_mnt(mnt, s); 394 394 395 395 return 0; 396 - 397 - out_dput: 398 - dput(s->s_root); /* undo dget() in simple_set_mnt() */ 399 396 400 397 out_undo_sget: 401 398 deactivate_locked_super(s);
+2 -22
fs/drop_caches.c
··· 12 12 /* A global variable is a bit ugly, but it keeps the code simple */ 13 13 int sysctl_drop_caches; 14 14 15 - static void drop_pagecache_sb(struct super_block *sb) 15 + static void drop_pagecache_sb(struct super_block *sb, void *unused) 16 16 { 17 17 struct inode *inode, *toput_inode = NULL; 18 18 ··· 33 33 iput(toput_inode); 34 34 } 35 35 36 - static void drop_pagecache(void) 37 - { 38 - struct super_block *sb; 39 - 40 - spin_lock(&sb_lock); 41 - restart: 42 - list_for_each_entry(sb, &super_blocks, s_list) { 43 - sb->s_count++; 44 - spin_unlock(&sb_lock); 45 - down_read(&sb->s_umount); 46 - if (sb->s_root) 47 - drop_pagecache_sb(sb); 48 - up_read(&sb->s_umount); 49 - spin_lock(&sb_lock); 50 - if (__put_super_and_need_restart(sb)) 51 - goto restart; 52 - } 53 - spin_unlock(&sb_lock); 54 - } 55 - 56 36 static void drop_slab(void) 57 37 { 58 38 int nr_objects; ··· 48 68 proc_dointvec_minmax(table, write, buffer, length, ppos); 49 69 if (write) { 50 70 if (sysctl_drop_caches & 1) 51 - drop_pagecache(); 71 + iterate_supers(drop_pagecache_sb, NULL); 52 72 if (sysctl_drop_caches & 2) 53 73 drop_slab(); 54 74 }
+2 -3
fs/ecryptfs/ecryptfs_kernel.h
··· 731 731 int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode, 732 732 struct page *page_for_lower, 733 733 size_t offset_in_page, size_t size); 734 - int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset, 735 - size_t size); 734 + int ecryptfs_write(struct inode *inode, char *data, loff_t offset, size_t size); 736 735 int ecryptfs_read_lower(char *data, loff_t offset, size_t size, 737 736 struct inode *ecryptfs_inode); 738 737 int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs, 739 738 pgoff_t page_index, 740 739 size_t offset_in_page, size_t size, 741 740 struct inode *ecryptfs_inode); 742 - struct page *ecryptfs_get_locked_page(struct file *file, loff_t index); 741 + struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index); 743 742 int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon); 744 743 int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid, 745 744 struct user_namespace *user_ns);
+1 -3
fs/ecryptfs/file.c
··· 276 276 static int 277 277 ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) 278 278 { 279 - return vfs_fsync(ecryptfs_file_to_lower(file), 280 - ecryptfs_dentry_to_lower(dentry), 281 - datasync); 279 + return vfs_fsync(ecryptfs_file_to_lower(file), datasync); 282 280 } 283 281 284 282 static int ecryptfs_fasync(int fd, struct file *file, int flag)
+8 -40
fs/ecryptfs/inode.c
··· 142 142 static int grow_file(struct dentry *ecryptfs_dentry) 143 143 { 144 144 struct inode *ecryptfs_inode = ecryptfs_dentry->d_inode; 145 - struct file fake_file; 146 - struct ecryptfs_file_info tmp_file_info; 147 145 char zero_virt[] = { 0x00 }; 148 146 int rc = 0; 149 147 150 - memset(&fake_file, 0, sizeof(fake_file)); 151 - fake_file.f_path.dentry = ecryptfs_dentry; 152 - memset(&tmp_file_info, 0, sizeof(tmp_file_info)); 153 - ecryptfs_set_file_private(&fake_file, &tmp_file_info); 154 - ecryptfs_set_file_lower( 155 - &fake_file, 156 - ecryptfs_inode_to_private(ecryptfs_inode)->lower_file); 157 - rc = ecryptfs_write(&fake_file, zero_virt, 0, 1); 148 + rc = ecryptfs_write(ecryptfs_inode, zero_virt, 0, 1); 158 149 i_size_write(ecryptfs_inode, 0); 159 150 rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); 160 151 ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat.flags |= ··· 775 784 { 776 785 int rc = 0; 777 786 struct inode *inode = dentry->d_inode; 778 - struct dentry *lower_dentry; 779 - struct file fake_ecryptfs_file; 780 787 struct ecryptfs_crypt_stat *crypt_stat; 781 788 loff_t i_size = i_size_read(inode); 782 789 loff_t lower_size_before_truncate; ··· 785 796 goto out; 786 797 } 787 798 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; 788 - /* Set up a fake ecryptfs file, this is used to interface with 789 - * the file in the underlying filesystem so that the 790 - * truncation has an effect there as well. */ 791 - memset(&fake_ecryptfs_file, 0, sizeof(fake_ecryptfs_file)); 792 - fake_ecryptfs_file.f_path.dentry = dentry; 793 - /* Released at out_free: label */ 794 - ecryptfs_set_file_private(&fake_ecryptfs_file, 795 - kmem_cache_alloc(ecryptfs_file_info_cache, 796 - GFP_KERNEL)); 797 - if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) { 798 - rc = -ENOMEM; 799 - goto out; 800 - } 801 - lower_dentry = ecryptfs_dentry_to_lower(dentry); 802 - ecryptfs_set_file_lower( 803 - &fake_ecryptfs_file, 804 - ecryptfs_inode_to_private(dentry->d_inode)->lower_file); 805 799 /* Switch on growing or shrinking file */ 806 800 if (ia->ia_size > i_size) { 807 801 char zero[] = { 0x00 }; ··· 794 822 * this triggers code that will fill in 0's throughout 795 823 * the intermediate portion of the previous end of the 796 824 * file and the new and of the file */ 797 - rc = ecryptfs_write(&fake_ecryptfs_file, zero, 825 + rc = ecryptfs_write(inode, zero, 798 826 (ia->ia_size - 1), 1); 799 827 } else { /* ia->ia_size < i_size_read(inode) */ 800 828 /* We're chopping off all the pages down to the page ··· 807 835 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { 808 836 rc = vmtruncate(inode, ia->ia_size); 809 837 if (rc) 810 - goto out_free; 838 + goto out; 811 839 lower_ia->ia_size = ia->ia_size; 812 840 lower_ia->ia_valid |= ATTR_SIZE; 813 - goto out_free; 841 + goto out; 814 842 } 815 843 if (num_zeros) { 816 844 char *zeros_virt; ··· 818 846 zeros_virt = kzalloc(num_zeros, GFP_KERNEL); 819 847 if (!zeros_virt) { 820 848 rc = -ENOMEM; 821 - goto out_free; 849 + goto out; 822 850 } 823 - rc = ecryptfs_write(&fake_ecryptfs_file, zeros_virt, 851 + rc = ecryptfs_write(inode, zeros_virt, 824 852 ia->ia_size, num_zeros); 825 853 kfree(zeros_virt); 826 854 if (rc) { 827 855 printk(KERN_ERR "Error attempting to zero out " 828 856 "the remainder of the end page on " 829 857 "reducing truncate; rc = [%d]\n", rc); 830 - goto out_free; 858 + goto out; 831 859 } 832 860 } 833 861 vmtruncate(inode, ia->ia_size); ··· 836 864 printk(KERN_ERR "Problem with " 837 865 "ecryptfs_write_inode_size_to_metadata; " 838 866 "rc = [%d]\n", rc); 839 - goto out_free; 867 + goto out; 840 868 } 841 869 /* We are reducing the size of the ecryptfs file, and need to 842 870 * know if we need to reduce the size of the lower file. */ ··· 850 878 } else 851 879 lower_ia->ia_valid &= ~ATTR_SIZE; 852 880 } 853 - out_free: 854 - if (ecryptfs_file_to_private(&fake_ecryptfs_file)) 855 - kmem_cache_free(ecryptfs_file_info_cache, 856 - ecryptfs_file_to_private(&fake_ecryptfs_file)); 857 881 out: 858 882 return rc; 859 883 }
+81 -85
fs/ecryptfs/main.c
··· 281 281 * 282 282 * Returns zero on success; non-zero on error 283 283 */ 284 - static int ecryptfs_parse_options(struct super_block *sb, char *options) 284 + static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options) 285 285 { 286 286 char *p; 287 287 int rc = 0; ··· 293 293 int fn_cipher_key_bytes; 294 294 int fn_cipher_key_bytes_set = 0; 295 295 struct ecryptfs_mount_crypt_stat *mount_crypt_stat = 296 - &ecryptfs_superblock_to_private(sb)->mount_crypt_stat; 296 + &sbi->mount_crypt_stat; 297 297 substring_t args[MAX_OPT_ARGS]; 298 298 int token; 299 299 char *sig_src; ··· 483 483 } 484 484 485 485 struct kmem_cache *ecryptfs_sb_info_cache; 486 - 487 - /** 488 - * ecryptfs_fill_super 489 - * @sb: The ecryptfs super block 490 - * @raw_data: The options passed to mount 491 - * @silent: Not used but required by function prototype 492 - * 493 - * Sets up what we can of the sb, rest is done in ecryptfs_read_super 494 - * 495 - * Returns zero on success; non-zero otherwise 496 - */ 497 - static int 498 - ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent) 499 - { 500 - struct ecryptfs_sb_info *esi; 501 - int rc = 0; 502 - 503 - /* Released in ecryptfs_put_super() */ 504 - ecryptfs_set_superblock_private(sb, 505 - kmem_cache_zalloc(ecryptfs_sb_info_cache, 506 - GFP_KERNEL)); 507 - esi = ecryptfs_superblock_to_private(sb); 508 - if (!esi) { 509 - ecryptfs_printk(KERN_WARNING, "Out of memory\n"); 510 - rc = -ENOMEM; 511 - goto out; 512 - } 513 - 514 - rc = bdi_setup_and_register(&esi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); 515 - if (rc) 516 - goto out; 517 - 518 - sb->s_bdi = &esi->bdi; 519 - sb->s_op = &ecryptfs_sops; 520 - /* Released through deactivate_super(sb) from get_sb_nodev */ 521 - sb->s_root = d_alloc(NULL, &(const struct qstr) { 522 - .hash = 0,.name = "/",.len = 1}); 523 - if (!sb->s_root) { 524 - ecryptfs_printk(KERN_ERR, "d_alloc failed\n"); 525 - rc = -ENOMEM; 526 - goto out; 527 - } 528 - sb->s_root->d_op = &ecryptfs_dops; 529 - sb->s_root->d_sb = sb; 530 - sb->s_root->d_parent = sb->s_root; 531 - /* Released in d_release when dput(sb->s_root) is called */ 532 - /* through deactivate_super(sb) from get_sb_nodev() */ 533 - ecryptfs_set_dentry_private(sb->s_root, 534 - kmem_cache_zalloc(ecryptfs_dentry_info_cache, 535 - GFP_KERNEL)); 536 - if (!ecryptfs_dentry_to_private(sb->s_root)) { 537 - ecryptfs_printk(KERN_ERR, 538 - "dentry_info_cache alloc failed\n"); 539 - rc = -ENOMEM; 540 - goto out; 541 - } 542 - rc = 0; 543 - out: 544 - /* Should be able to rely on deactivate_super called from 545 - * get_sb_nodev */ 546 - return rc; 547 - } 486 + static struct file_system_type ecryptfs_fs_type; 548 487 549 488 /** 550 489 * ecryptfs_read_super ··· 503 564 if (rc) { 504 565 ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n"); 505 566 goto out; 567 + } 568 + if (path.dentry->d_sb->s_type == &ecryptfs_fs_type) { 569 + rc = -EINVAL; 570 + printk(KERN_ERR "Mount on filesystem of type " 571 + "eCryptfs explicitly disallowed due to " 572 + "known incompatibilities\n"); 573 + goto out_free; 506 574 } 507 575 ecryptfs_set_superblock_lower(sb, path.dentry->d_sb); 508 576 sb->s_maxbytes = path.dentry->d_sb->s_maxbytes; ··· 534 588 * @dev_name: The path to mount over 535 589 * @raw_data: The options passed into the kernel 536 590 * 537 - * The whole ecryptfs_get_sb process is broken into 4 functions: 591 + * The whole ecryptfs_get_sb process is broken into 3 functions: 538 592 * ecryptfs_parse_options(): handle options passed to ecryptfs, if any 539 - * ecryptfs_fill_super(): used by get_sb_nodev, fills out the super_block 540 - * with as much information as it can before needing 541 - * the lower filesystem. 542 593 * ecryptfs_read_super(): this accesses the lower filesystem and uses 543 594 * ecryptfs_interpose to perform most of the linking 544 595 * ecryptfs_interpose(): links the lower filesystem into ecryptfs (inode.c) ··· 544 601 const char *dev_name, void *raw_data, 545 602 struct vfsmount *mnt) 546 603 { 604 + struct super_block *s; 605 + struct ecryptfs_sb_info *sbi; 606 + struct ecryptfs_dentry_info *root_info; 607 + const char *err = "Getting sb failed"; 547 608 int rc; 548 - struct super_block *sb; 549 609 550 - rc = get_sb_nodev(fs_type, flags, raw_data, ecryptfs_fill_super, mnt); 551 - if (rc < 0) { 552 - printk(KERN_ERR "Getting sb failed; rc = [%d]\n", rc); 610 + sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL); 611 + if (!sbi) { 612 + rc = -ENOMEM; 553 613 goto out; 554 614 } 555 - sb = mnt->mnt_sb; 556 - rc = ecryptfs_parse_options(sb, raw_data); 615 + 616 + rc = ecryptfs_parse_options(sbi, raw_data); 557 617 if (rc) { 558 - printk(KERN_ERR "Error parsing options; rc = [%d]\n", rc); 559 - goto out_abort; 618 + err = "Error parsing options"; 619 + goto out; 560 620 } 561 - rc = ecryptfs_read_super(sb, dev_name); 621 + 622 + s = sget(fs_type, NULL, set_anon_super, NULL); 623 + if (IS_ERR(s)) { 624 + rc = PTR_ERR(s); 625 + goto out; 626 + } 627 + 628 + s->s_flags = flags; 629 + rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); 562 630 if (rc) { 563 - printk(KERN_ERR "Reading sb failed; rc = [%d]\n", rc); 564 - goto out_abort; 631 + deactivate_locked_super(s); 632 + goto out; 565 633 } 566 - goto out; 567 - out_abort: 568 - dput(sb->s_root); /* aka mnt->mnt_root, as set by get_sb_nodev() */ 569 - deactivate_locked_super(sb); 634 + 635 + ecryptfs_set_superblock_private(s, sbi); 636 + s->s_bdi = &sbi->bdi; 637 + 638 + /* ->kill_sb() will take care of sbi after that point */ 639 + sbi = NULL; 640 + s->s_op = &ecryptfs_sops; 641 + 642 + rc = -ENOMEM; 643 + s->s_root = d_alloc(NULL, &(const struct qstr) { 644 + .hash = 0,.name = "/",.len = 1}); 645 + if (!s->s_root) { 646 + deactivate_locked_super(s); 647 + goto out; 648 + } 649 + s->s_root->d_op = &ecryptfs_dops; 650 + s->s_root->d_sb = s; 651 + s->s_root->d_parent = s->s_root; 652 + 653 + root_info = kmem_cache_zalloc(ecryptfs_dentry_info_cache, GFP_KERNEL); 654 + if (!root_info) { 655 + deactivate_locked_super(s); 656 + goto out; 657 + } 658 + /* ->kill_sb() will take care of root_info */ 659 + ecryptfs_set_dentry_private(s->s_root, root_info); 660 + s->s_flags |= MS_ACTIVE; 661 + rc = ecryptfs_read_super(s, dev_name); 662 + if (rc) { 663 + deactivate_locked_super(s); 664 + err = "Reading sb failed"; 665 + goto out; 666 + } 667 + simple_set_mnt(mnt, s); 668 + return 0; 669 + 570 670 out: 671 + if (sbi) { 672 + ecryptfs_destroy_mount_crypt_stat(&sbi->mount_crypt_stat); 673 + kmem_cache_free(ecryptfs_sb_info_cache, sbi); 674 + } 675 + printk(KERN_ERR "%s; rc = [%d]\n", err, rc); 571 676 return rc; 572 677 } 573 678 ··· 624 633 * @sb: The ecryptfs super block 625 634 * 626 635 * Used to bring the superblock down and free the private data. 627 - * Private data is free'd in ecryptfs_put_super() 628 636 */ 629 637 static void ecryptfs_kill_block_super(struct super_block *sb) 630 638 { 631 - generic_shutdown_super(sb); 639 + struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb); 640 + kill_anon_super(sb); 641 + if (!sb_info) 642 + return; 643 + ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat); 644 + bdi_destroy(&sb_info->bdi); 645 + kmem_cache_free(ecryptfs_sb_info_cache, sb_info); 632 646 } 633 647 634 648 static struct file_system_type ecryptfs_fs_type = {
+5 -14
fs/ecryptfs/mmap.c
··· 44 44 * Returns locked and up-to-date page (if ok), with increased 45 45 * refcnt. 46 46 */ 47 - struct page *ecryptfs_get_locked_page(struct file *file, loff_t index) 47 + struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index) 48 48 { 49 - struct dentry *dentry; 50 - struct inode *inode; 51 - struct address_space *mapping; 52 - struct page *page; 53 - 54 - dentry = file->f_path.dentry; 55 - inode = dentry->d_inode; 56 - mapping = inode->i_mapping; 57 - page = read_mapping_page(mapping, index, (void *)file); 49 + struct page *page = read_mapping_page(inode->i_mapping, index, NULL); 58 50 if (!IS_ERR(page)) 59 51 lock_page(page); 60 52 return page; ··· 190 198 static int ecryptfs_readpage(struct file *file, struct page *page) 191 199 { 192 200 struct ecryptfs_crypt_stat *crypt_stat = 193 - &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)->crypt_stat; 201 + &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; 194 202 int rc = 0; 195 203 196 204 if (!crypt_stat ··· 292 300 293 301 if (!PageUptodate(page)) { 294 302 struct ecryptfs_crypt_stat *crypt_stat = 295 - &ecryptfs_inode_to_private( 296 - file->f_path.dentry->d_inode)->crypt_stat; 303 + &ecryptfs_inode_to_private(mapping->host)->crypt_stat; 297 304 298 305 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED) 299 306 || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) { ··· 478 487 unsigned to = from + copied; 479 488 struct inode *ecryptfs_inode = mapping->host; 480 489 struct ecryptfs_crypt_stat *crypt_stat = 481 - &ecryptfs_inode_to_private(file->f_path.dentry->d_inode)->crypt_stat; 490 + &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; 482 491 int rc; 483 492 484 493 if (crypt_stat->flags & ECRYPTFS_NEW_FILE) {
+6 -7
fs/ecryptfs/read_write.c
··· 93 93 94 94 /** 95 95 * ecryptfs_write 96 - * @ecryptfs_file: The eCryptfs file into which to write 96 + * @ecryptfs_inode: The eCryptfs file into which to write 97 97 * @data: Virtual address where data to write is located 98 98 * @offset: Offset in the eCryptfs file at which to begin writing the 99 99 * data from @data ··· 109 109 * 110 110 * Returns zero on success; non-zero otherwise 111 111 */ 112 - int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset, 112 + int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset, 113 113 size_t size) 114 114 { 115 115 struct page *ecryptfs_page; 116 116 struct ecryptfs_crypt_stat *crypt_stat; 117 - struct inode *ecryptfs_inode = ecryptfs_file->f_dentry->d_inode; 118 117 char *ecryptfs_page_virt; 119 118 loff_t ecryptfs_file_size = i_size_read(ecryptfs_inode); 120 119 loff_t data_offset = 0; ··· 144 145 if (num_bytes > total_remaining_zeros) 145 146 num_bytes = total_remaining_zeros; 146 147 } 147 - ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_file, 148 + ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_inode, 148 149 ecryptfs_page_idx); 149 150 if (IS_ERR(ecryptfs_page)) { 150 151 rc = PTR_ERR(ecryptfs_page); ··· 301 302 int ecryptfs_read(char *data, loff_t offset, size_t size, 302 303 struct file *ecryptfs_file) 303 304 { 305 + struct inode *ecryptfs_inode = ecryptfs_file->f_dentry->d_inode; 304 306 struct page *ecryptfs_page; 305 307 char *ecryptfs_page_virt; 306 - loff_t ecryptfs_file_size = 307 - i_size_read(ecryptfs_file->f_dentry->d_inode); 308 + loff_t ecryptfs_file_size = i_size_read(ecryptfs_inode); 308 309 loff_t data_offset = 0; 309 310 loff_t pos; 310 311 int rc = 0; ··· 326 327 327 328 if (num_bytes > total_remaining_bytes) 328 329 num_bytes = total_remaining_bytes; 329 - ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_file, 330 + ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_inode, 330 331 ecryptfs_page_idx); 331 332 if (IS_ERR(ecryptfs_page)) { 332 333 rc = PTR_ERR(ecryptfs_page);
-22
fs/ecryptfs/super.c
··· 109 109 } 110 110 111 111 /** 112 - * ecryptfs_put_super 113 - * @sb: Pointer to the ecryptfs super block 114 - * 115 - * Final actions when unmounting a file system. 116 - * This will handle deallocation and release of our private data. 117 - */ 118 - static void ecryptfs_put_super(struct super_block *sb) 119 - { 120 - struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb); 121 - 122 - lock_kernel(); 123 - 124 - ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat); 125 - bdi_destroy(&sb_info->bdi); 126 - kmem_cache_free(ecryptfs_sb_info_cache, sb_info); 127 - ecryptfs_set_superblock_private(sb, NULL); 128 - 129 - unlock_kernel(); 130 - } 131 - 132 - /** 133 112 * ecryptfs_statfs 134 113 * @sb: The ecryptfs super block 135 114 * @buf: The struct kstatfs to fill in with stats ··· 182 203 .alloc_inode = ecryptfs_alloc_inode, 183 204 .destroy_inode = ecryptfs_destroy_inode, 184 205 .drop_inode = generic_delete_inode, 185 - .put_super = ecryptfs_put_super, 186 206 .statfs = ecryptfs_statfs, 187 207 .remount_fs = NULL, 188 208 .clear_inode = ecryptfs_clear_inode,
+1 -10
fs/exofs/inode.c
··· 1123 1123 sbi = sb->s_fs_info; 1124 1124 1125 1125 sb->s_dirt = 1; 1126 - inode->i_uid = current->cred->fsuid; 1127 - if (dir->i_mode & S_ISGID) { 1128 - inode->i_gid = dir->i_gid; 1129 - if (S_ISDIR(mode)) 1130 - mode |= S_ISGID; 1131 - } else { 1132 - inode->i_gid = current->cred->fsgid; 1133 - } 1134 - inode->i_mode = mode; 1135 - 1126 + inode_init_owner(inode, dir, mode); 1136 1127 inode->i_ino = sbi->s_nextid++; 1137 1128 inode->i_blkbits = EXOFS_BLKSHIFT; 1138 1129 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+2 -2
fs/ext2/acl.c
··· 420 420 return error; 421 421 } 422 422 423 - struct xattr_handler ext2_xattr_acl_access_handler = { 423 + const struct xattr_handler ext2_xattr_acl_access_handler = { 424 424 .prefix = POSIX_ACL_XATTR_ACCESS, 425 425 .flags = ACL_TYPE_ACCESS, 426 426 .list = ext2_xattr_list_acl_access, ··· 428 428 .set = ext2_xattr_set_acl, 429 429 }; 430 430 431 - struct xattr_handler ext2_xattr_acl_default_handler = { 431 + const struct xattr_handler ext2_xattr_acl_default_handler = { 432 432 .prefix = POSIX_ACL_XATTR_DEFAULT, 433 433 .flags = ACL_TYPE_DEFAULT, 434 434 .list = ext2_xattr_list_acl_default,
+4 -8
fs/ext2/ialloc.c
··· 549 549 550 550 sb->s_dirt = 1; 551 551 mark_buffer_dirty(bh2); 552 - inode->i_uid = current_fsuid(); 553 - if (test_opt (sb, GRPID)) 552 + if (test_opt(sb, GRPID)) { 553 + inode->i_mode = mode; 554 + inode->i_uid = current_fsuid(); 554 555 inode->i_gid = dir->i_gid; 555 - else if (dir->i_mode & S_ISGID) { 556 - inode->i_gid = dir->i_gid; 557 - if (S_ISDIR(mode)) 558 - mode |= S_ISGID; 559 556 } else 560 - inode->i_gid = current_fsgid(); 561 - inode->i_mode = mode; 557 + inode_init_owner(inode, dir, mode); 562 558 563 559 inode->i_ino = ino; 564 560 inode->i_blocks = 0;
+5 -5
fs/ext2/xattr.c
··· 101 101 102 102 static struct mb_cache *ext2_xattr_cache; 103 103 104 - static struct xattr_handler *ext2_xattr_handler_map[] = { 104 + static const struct xattr_handler *ext2_xattr_handler_map[] = { 105 105 [EXT2_XATTR_INDEX_USER] = &ext2_xattr_user_handler, 106 106 #ifdef CONFIG_EXT2_FS_POSIX_ACL 107 107 [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext2_xattr_acl_access_handler, ··· 113 113 #endif 114 114 }; 115 115 116 - struct xattr_handler *ext2_xattr_handlers[] = { 116 + const struct xattr_handler *ext2_xattr_handlers[] = { 117 117 &ext2_xattr_user_handler, 118 118 &ext2_xattr_trusted_handler, 119 119 #ifdef CONFIG_EXT2_FS_POSIX_ACL ··· 126 126 NULL 127 127 }; 128 128 129 - static inline struct xattr_handler * 129 + static inline const struct xattr_handler * 130 130 ext2_xattr_handler(int name_index) 131 131 { 132 - struct xattr_handler *handler = NULL; 132 + const struct xattr_handler *handler = NULL; 133 133 134 134 if (name_index > 0 && name_index < ARRAY_SIZE(ext2_xattr_handler_map)) 135 135 handler = ext2_xattr_handler_map[name_index]; ··· 298 298 /* list the attribute names */ 299 299 for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry); 300 300 entry = EXT2_XATTR_NEXT(entry)) { 301 - struct xattr_handler *handler = 301 + const struct xattr_handler *handler = 302 302 ext2_xattr_handler(entry->e_name_index); 303 303 304 304 if (handler) {
+6 -6
fs/ext2/xattr.h
··· 55 55 56 56 # ifdef CONFIG_EXT2_FS_XATTR 57 57 58 - extern struct xattr_handler ext2_xattr_user_handler; 59 - extern struct xattr_handler ext2_xattr_trusted_handler; 60 - extern struct xattr_handler ext2_xattr_acl_access_handler; 61 - extern struct xattr_handler ext2_xattr_acl_default_handler; 62 - extern struct xattr_handler ext2_xattr_security_handler; 58 + extern const struct xattr_handler ext2_xattr_user_handler; 59 + extern const struct xattr_handler ext2_xattr_trusted_handler; 60 + extern const struct xattr_handler ext2_xattr_acl_access_handler; 61 + extern const struct xattr_handler ext2_xattr_acl_default_handler; 62 + extern const struct xattr_handler ext2_xattr_security_handler; 63 63 64 64 extern ssize_t ext2_listxattr(struct dentry *, char *, size_t); 65 65 ··· 72 72 extern int init_ext2_xattr(void); 73 73 extern void exit_ext2_xattr(void); 74 74 75 - extern struct xattr_handler *ext2_xattr_handlers[]; 75 + extern const struct xattr_handler *ext2_xattr_handlers[]; 76 76 77 77 # else /* CONFIG_EXT2_FS_XATTR */ 78 78
+1 -1
fs/ext2/xattr_security.c
··· 67 67 return err; 68 68 } 69 69 70 - struct xattr_handler ext2_xattr_security_handler = { 70 + const struct xattr_handler ext2_xattr_security_handler = { 71 71 .prefix = XATTR_SECURITY_PREFIX, 72 72 .list = ext2_xattr_security_list, 73 73 .get = ext2_xattr_security_get,
+1 -1
fs/ext2/xattr_trusted.c
··· 50 50 value, size, flags); 51 51 } 52 52 53 - struct xattr_handler ext2_xattr_trusted_handler = { 53 + const struct xattr_handler ext2_xattr_trusted_handler = { 54 54 .prefix = XATTR_TRUSTED_PREFIX, 55 55 .list = ext2_xattr_trusted_list, 56 56 .get = ext2_xattr_trusted_get,
+1 -1
fs/ext2/xattr_user.c
··· 54 54 name, value, size, flags); 55 55 } 56 56 57 - struct xattr_handler ext2_xattr_user_handler = { 57 + const struct xattr_handler ext2_xattr_user_handler = { 58 58 .prefix = XATTR_USER_PREFIX, 59 59 .list = ext2_xattr_user_list, 60 60 .get = ext2_xattr_user_get,
+2 -2
fs/ext3/acl.c
··· 456 456 return error; 457 457 } 458 458 459 - struct xattr_handler ext3_xattr_acl_access_handler = { 459 + const struct xattr_handler ext3_xattr_acl_access_handler = { 460 460 .prefix = POSIX_ACL_XATTR_ACCESS, 461 461 .flags = ACL_TYPE_ACCESS, 462 462 .list = ext3_xattr_list_acl_access, ··· 464 464 .set = ext3_xattr_set_acl, 465 465 }; 466 466 467 - struct xattr_handler ext3_xattr_acl_default_handler = { 467 + const struct xattr_handler ext3_xattr_acl_default_handler = { 468 468 .prefix = POSIX_ACL_XATTR_DEFAULT, 469 469 .flags = ACL_TYPE_DEFAULT, 470 470 .list = ext3_xattr_list_acl_default,
+5 -8
fs/ext3/ialloc.c
··· 538 538 if (S_ISDIR(mode)) 539 539 percpu_counter_inc(&sbi->s_dirs_counter); 540 540 541 - inode->i_uid = current_fsuid(); 542 - if (test_opt (sb, GRPID)) 541 + 542 + if (test_opt(sb, GRPID)) { 543 + inode->i_mode = mode; 544 + inode->i_uid = current_fsuid(); 543 545 inode->i_gid = dir->i_gid; 544 - else if (dir->i_mode & S_ISGID) { 545 - inode->i_gid = dir->i_gid; 546 - if (S_ISDIR(mode)) 547 - mode |= S_ISGID; 548 546 } else 549 - inode->i_gid = current_fsgid(); 550 - inode->i_mode = mode; 547 + inode_init_owner(inode, dir, mode); 551 548 552 549 inode->i_ino = ino; 553 550 /* This is the optimal IO size (for stat), not the fs block size */
+5 -5
fs/ext3/xattr.c
··· 104 104 105 105 static struct mb_cache *ext3_xattr_cache; 106 106 107 - static struct xattr_handler *ext3_xattr_handler_map[] = { 107 + static const struct xattr_handler *ext3_xattr_handler_map[] = { 108 108 [EXT3_XATTR_INDEX_USER] = &ext3_xattr_user_handler, 109 109 #ifdef CONFIG_EXT3_FS_POSIX_ACL 110 110 [EXT3_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext3_xattr_acl_access_handler, ··· 116 116 #endif 117 117 }; 118 118 119 - struct xattr_handler *ext3_xattr_handlers[] = { 119 + const struct xattr_handler *ext3_xattr_handlers[] = { 120 120 &ext3_xattr_user_handler, 121 121 &ext3_xattr_trusted_handler, 122 122 #ifdef CONFIG_EXT3_FS_POSIX_ACL ··· 129 129 NULL 130 130 }; 131 131 132 - static inline struct xattr_handler * 132 + static inline const struct xattr_handler * 133 133 ext3_xattr_handler(int name_index) 134 134 { 135 - struct xattr_handler *handler = NULL; 135 + const struct xattr_handler *handler = NULL; 136 136 137 137 if (name_index > 0 && name_index < ARRAY_SIZE(ext3_xattr_handler_map)) 138 138 handler = ext3_xattr_handler_map[name_index]; ··· 338 338 size_t rest = buffer_size; 339 339 340 340 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) { 341 - struct xattr_handler *handler = 341 + const struct xattr_handler *handler = 342 342 ext3_xattr_handler(entry->e_name_index); 343 343 344 344 if (handler) {
+6 -6
fs/ext3/xattr.h
··· 58 58 59 59 # ifdef CONFIG_EXT3_FS_XATTR 60 60 61 - extern struct xattr_handler ext3_xattr_user_handler; 62 - extern struct xattr_handler ext3_xattr_trusted_handler; 63 - extern struct xattr_handler ext3_xattr_acl_access_handler; 64 - extern struct xattr_handler ext3_xattr_acl_default_handler; 65 - extern struct xattr_handler ext3_xattr_security_handler; 61 + extern const struct xattr_handler ext3_xattr_user_handler; 62 + extern const struct xattr_handler ext3_xattr_trusted_handler; 63 + extern const struct xattr_handler ext3_xattr_acl_access_handler; 64 + extern const struct xattr_handler ext3_xattr_acl_default_handler; 65 + extern const struct xattr_handler ext3_xattr_security_handler; 66 66 67 67 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t); 68 68 ··· 76 76 extern int init_ext3_xattr(void); 77 77 extern void exit_ext3_xattr(void); 78 78 79 - extern struct xattr_handler *ext3_xattr_handlers[]; 79 + extern const struct xattr_handler *ext3_xattr_handlers[]; 80 80 81 81 # else /* CONFIG_EXT3_FS_XATTR */ 82 82
+1 -1
fs/ext3/xattr_security.c
··· 69 69 return err; 70 70 } 71 71 72 - struct xattr_handler ext3_xattr_security_handler = { 72 + const struct xattr_handler ext3_xattr_security_handler = { 73 73 .prefix = XATTR_SECURITY_PREFIX, 74 74 .list = ext3_xattr_security_list, 75 75 .get = ext3_xattr_security_get,
+1 -1
fs/ext3/xattr_trusted.c
··· 51 51 value, size, flags); 52 52 } 53 53 54 - struct xattr_handler ext3_xattr_trusted_handler = { 54 + const struct xattr_handler ext3_xattr_trusted_handler = { 55 55 .prefix = XATTR_TRUSTED_PREFIX, 56 56 .list = ext3_xattr_trusted_list, 57 57 .get = ext3_xattr_trusted_get,
+1 -1
fs/ext3/xattr_user.c
··· 54 54 name, value, size, flags); 55 55 } 56 56 57 - struct xattr_handler ext3_xattr_user_handler = { 57 + const struct xattr_handler ext3_xattr_user_handler = { 58 58 .prefix = XATTR_USER_PREFIX, 59 59 .list = ext3_xattr_user_list, 60 60 .get = ext3_xattr_user_get,
+2 -2
fs/ext4/acl.c
··· 454 454 return error; 455 455 } 456 456 457 - struct xattr_handler ext4_xattr_acl_access_handler = { 457 + const struct xattr_handler ext4_xattr_acl_access_handler = { 458 458 .prefix = POSIX_ACL_XATTR_ACCESS, 459 459 .flags = ACL_TYPE_ACCESS, 460 460 .list = ext4_xattr_list_acl_access, ··· 462 462 .set = ext4_xattr_set_acl, 463 463 }; 464 464 465 - struct xattr_handler ext4_xattr_acl_default_handler = { 465 + const struct xattr_handler ext4_xattr_acl_default_handler = { 466 466 .prefix = POSIX_ACL_XATTR_DEFAULT, 467 467 .flags = ACL_TYPE_DEFAULT, 468 468 .list = ext4_xattr_list_acl_default,
+4 -8
fs/ext4/ialloc.c
··· 979 979 atomic_dec(&sbi->s_flex_groups[flex_group].free_inodes); 980 980 } 981 981 982 - inode->i_uid = current_fsuid(); 983 - if (test_opt(sb, GRPID)) 982 + if (test_opt(sb, GRPID)) { 983 + inode->i_mode = mode; 984 + inode->i_uid = current_fsuid(); 984 985 inode->i_gid = dir->i_gid; 985 - else if (dir->i_mode & S_ISGID) { 986 - inode->i_gid = dir->i_gid; 987 - if (S_ISDIR(mode)) 988 - mode |= S_ISGID; 989 986 } else 990 - inode->i_gid = current_fsgid(); 991 - inode->i_mode = mode; 987 + inode_init_owner(inode, dir, mode); 992 988 993 989 inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb); 994 990 /* This is the optimal IO size (for stat), not the fs block size */
+5 -5
fs/ext4/xattr.c
··· 97 97 98 98 static struct mb_cache *ext4_xattr_cache; 99 99 100 - static struct xattr_handler *ext4_xattr_handler_map[] = { 100 + static const struct xattr_handler *ext4_xattr_handler_map[] = { 101 101 [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler, 102 102 #ifdef CONFIG_EXT4_FS_POSIX_ACL 103 103 [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler, ··· 109 109 #endif 110 110 }; 111 111 112 - struct xattr_handler *ext4_xattr_handlers[] = { 112 + const struct xattr_handler *ext4_xattr_handlers[] = { 113 113 &ext4_xattr_user_handler, 114 114 &ext4_xattr_trusted_handler, 115 115 #ifdef CONFIG_EXT4_FS_POSIX_ACL ··· 122 122 NULL 123 123 }; 124 124 125 - static inline struct xattr_handler * 125 + static inline const struct xattr_handler * 126 126 ext4_xattr_handler(int name_index) 127 127 { 128 - struct xattr_handler *handler = NULL; 128 + const struct xattr_handler *handler = NULL; 129 129 130 130 if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map)) 131 131 handler = ext4_xattr_handler_map[name_index]; ··· 332 332 size_t rest = buffer_size; 333 333 334 334 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { 335 - struct xattr_handler *handler = 335 + const struct xattr_handler *handler = 336 336 ext4_xattr_handler(entry->e_name_index); 337 337 338 338 if (handler) {
+6 -6
fs/ext4/xattr.h
··· 65 65 66 66 # ifdef CONFIG_EXT4_FS_XATTR 67 67 68 - extern struct xattr_handler ext4_xattr_user_handler; 69 - extern struct xattr_handler ext4_xattr_trusted_handler; 70 - extern struct xattr_handler ext4_xattr_acl_access_handler; 71 - extern struct xattr_handler ext4_xattr_acl_default_handler; 72 - extern struct xattr_handler ext4_xattr_security_handler; 68 + extern const struct xattr_handler ext4_xattr_user_handler; 69 + extern const struct xattr_handler ext4_xattr_trusted_handler; 70 + extern const struct xattr_handler ext4_xattr_acl_access_handler; 71 + extern const struct xattr_handler ext4_xattr_acl_default_handler; 72 + extern const struct xattr_handler ext4_xattr_security_handler; 73 73 74 74 extern ssize_t ext4_listxattr(struct dentry *, char *, size_t); 75 75 ··· 86 86 extern int init_ext4_xattr(void); 87 87 extern void exit_ext4_xattr(void); 88 88 89 - extern struct xattr_handler *ext4_xattr_handlers[]; 89 + extern const struct xattr_handler *ext4_xattr_handlers[]; 90 90 91 91 # else /* CONFIG_EXT4_FS_XATTR */ 92 92
+1 -1
fs/ext4/xattr_security.c
··· 69 69 return err; 70 70 } 71 71 72 - struct xattr_handler ext4_xattr_security_handler = { 72 + const struct xattr_handler ext4_xattr_security_handler = { 73 73 .prefix = XATTR_SECURITY_PREFIX, 74 74 .list = ext4_xattr_security_list, 75 75 .get = ext4_xattr_security_get,
+1 -1
fs/ext4/xattr_trusted.c
··· 51 51 name, value, size, flags); 52 52 } 53 53 54 - struct xattr_handler ext4_xattr_trusted_handler = { 54 + const struct xattr_handler ext4_xattr_trusted_handler = { 55 55 .prefix = XATTR_TRUSTED_PREFIX, 56 56 .list = ext4_xattr_trusted_list, 57 57 .get = ext4_xattr_trusted_get,
+1 -1
fs/ext4/xattr_user.c
··· 54 54 name, value, size, flags); 55 55 } 56 56 57 - struct xattr_handler ext4_xattr_user_handler = { 57 + const struct xattr_handler ext4_xattr_user_handler = { 58 58 .prefix = XATTR_USER_PREFIX, 59 59 .list = ext4_xattr_user_list, 60 60 .get = ext4_xattr_user_get,
+4 -4
fs/fs-writeback.c
··· 42 42 long nr_pages; 43 43 struct super_block *sb; 44 44 enum writeback_sync_modes sync_mode; 45 - int for_kupdate:1; 46 - int range_cyclic:1; 47 - int for_background:1; 48 - int sb_pinned:1; 45 + unsigned int for_kupdate:1; 46 + unsigned int range_cyclic:1; 47 + unsigned int for_background:1; 48 + unsigned int sb_pinned:1; 49 49 }; 50 50 51 51 /*
+2 -2
fs/generic_acl.c
··· 201 201 return -EAGAIN; 202 202 } 203 203 204 - struct xattr_handler generic_acl_access_handler = { 204 + const struct xattr_handler generic_acl_access_handler = { 205 205 .prefix = POSIX_ACL_XATTR_ACCESS, 206 206 .flags = ACL_TYPE_ACCESS, 207 207 .list = generic_acl_list, ··· 209 209 .set = generic_acl_set, 210 210 }; 211 211 212 - struct xattr_handler generic_acl_default_handler = { 212 + const struct xattr_handler generic_acl_default_handler = { 213 213 .prefix = POSIX_ACL_XATTR_DEFAULT, 214 214 .flags = ACL_TYPE_DEFAULT, 215 215 .list = generic_acl_list,
+1 -1
fs/gfs2/acl.c
··· 335 335 return error; 336 336 } 337 337 338 - struct xattr_handler gfs2_xattr_system_handler = { 338 + const struct xattr_handler gfs2_xattr_system_handler = { 339 339 .prefix = XATTR_SYSTEM_PREFIX, 340 340 .flags = GFS2_EATYPE_SYS, 341 341 .get = gfs2_xattr_system_get,
+1 -1
fs/gfs2/acl.h
··· 19 19 extern int gfs2_check_acl(struct inode *inode, int mask); 20 20 extern int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode); 21 21 extern int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr); 22 - extern struct xattr_handler gfs2_xattr_system_handler; 22 + extern const struct xattr_handler gfs2_xattr_system_handler; 23 23 24 24 #endif /* __ACL_DOT_H__ */
+1 -1
fs/gfs2/super.h
··· 54 54 extern const struct export_operations gfs2_export_ops; 55 55 extern const struct super_operations gfs2_super_ops; 56 56 extern const struct dentry_operations gfs2_dops; 57 - extern struct xattr_handler *gfs2_xattr_handlers[]; 57 + extern const struct xattr_handler *gfs2_xattr_handlers[]; 58 58 59 59 #endif /* __SUPER_DOT_H__ */ 60 60
+3 -3
fs/gfs2/xattr.c
··· 1535 1535 return error; 1536 1536 } 1537 1537 1538 - static struct xattr_handler gfs2_xattr_user_handler = { 1538 + static const struct xattr_handler gfs2_xattr_user_handler = { 1539 1539 .prefix = XATTR_USER_PREFIX, 1540 1540 .flags = GFS2_EATYPE_USR, 1541 1541 .get = gfs2_xattr_get, 1542 1542 .set = gfs2_xattr_set, 1543 1543 }; 1544 1544 1545 - static struct xattr_handler gfs2_xattr_security_handler = { 1545 + static const struct xattr_handler gfs2_xattr_security_handler = { 1546 1546 .prefix = XATTR_SECURITY_PREFIX, 1547 1547 .flags = GFS2_EATYPE_SECURITY, 1548 1548 .get = gfs2_xattr_get, 1549 1549 .set = gfs2_xattr_set, 1550 1550 }; 1551 1551 1552 - struct xattr_handler *gfs2_xattr_handlers[] = { 1552 + const struct xattr_handler *gfs2_xattr_handlers[] = { 1553 1553 &gfs2_xattr_user_handler, 1554 1554 &gfs2_xattr_security_handler, 1555 1555 &gfs2_xattr_system_handler,
+22 -4
fs/inode.c
··· 286 286 */ 287 287 void __iget(struct inode *inode) 288 288 { 289 - if (atomic_read(&inode->i_count)) { 290 - atomic_inc(&inode->i_count); 289 + if (atomic_inc_return(&inode->i_count) != 1) 291 290 return; 292 - } 293 - atomic_inc(&inode->i_count); 291 + 294 292 if (!(inode->i_state & (I_DIRTY|I_SYNC))) 295 293 list_move(&inode->i_list, &inode_in_use); 296 294 inodes_stat.nr_unused--; ··· 1606 1608 inode->i_ino); 1607 1609 } 1608 1610 EXPORT_SYMBOL(init_special_inode); 1611 + 1612 + /** 1613 + * Init uid,gid,mode for new inode according to posix standards 1614 + * @inode: New inode 1615 + * @dir: Directory inode 1616 + * @mode: mode of the new inode 1617 + */ 1618 + void inode_init_owner(struct inode *inode, const struct inode *dir, 1619 + mode_t mode) 1620 + { 1621 + inode->i_uid = current_fsuid(); 1622 + if (dir && dir->i_mode & S_ISGID) { 1623 + inode->i_gid = dir->i_gid; 1624 + if (S_ISDIR(mode)) 1625 + mode |= S_ISGID; 1626 + } else 1627 + inode->i_gid = current_fsgid(); 1628 + inode->i_mode = mode; 1629 + } 1630 + EXPORT_SYMBOL(inode_init_owner);
+2
fs/internal.h
··· 87 87 * super.c 88 88 */ 89 89 extern int do_remount_sb(struct super_block *, int, void *, int); 90 + extern void __put_super(struct super_block *sb); 91 + extern void put_super(struct super_block *sb); 90 92 91 93 /* 92 94 * open.c
+2 -13
fs/ioctl.c
··· 525 525 if (sb->s_op->freeze_fs == NULL) 526 526 return -EOPNOTSUPP; 527 527 528 - /* If a blockdevice-backed filesystem isn't specified, return. */ 529 - if (sb->s_bdev == NULL) 530 - return -EINVAL; 531 - 532 528 /* Freeze */ 533 - sb = freeze_bdev(sb->s_bdev); 534 - if (IS_ERR(sb)) 535 - return PTR_ERR(sb); 536 - return 0; 529 + return freeze_super(sb); 537 530 } 538 531 539 532 static int ioctl_fsthaw(struct file *filp) ··· 536 543 if (!capable(CAP_SYS_ADMIN)) 537 544 return -EPERM; 538 545 539 - /* If a blockdevice-backed filesystem isn't specified, return EINVAL. */ 540 - if (sb->s_bdev == NULL) 541 - return -EINVAL; 542 - 543 546 /* Thaw */ 544 - return thaw_bdev(sb->s_bdev, sb); 547 + return thaw_super(sb); 545 548 } 546 549 547 550 /*
+2 -2
fs/jffs2/acl.c
··· 419 419 return rc; 420 420 } 421 421 422 - struct xattr_handler jffs2_acl_access_xattr_handler = { 422 + const struct xattr_handler jffs2_acl_access_xattr_handler = { 423 423 .prefix = POSIX_ACL_XATTR_ACCESS, 424 424 .flags = ACL_TYPE_DEFAULT, 425 425 .list = jffs2_acl_access_listxattr, ··· 427 427 .set = jffs2_acl_setxattr, 428 428 }; 429 429 430 - struct xattr_handler jffs2_acl_default_xattr_handler = { 430 + const struct xattr_handler jffs2_acl_default_xattr_handler = { 431 431 .prefix = POSIX_ACL_XATTR_DEFAULT, 432 432 .flags = ACL_TYPE_DEFAULT, 433 433 .list = jffs2_acl_default_listxattr,
+2 -2
fs/jffs2/acl.h
··· 31 31 extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); 32 32 extern int jffs2_init_acl_post(struct inode *); 33 33 34 - extern struct xattr_handler jffs2_acl_access_xattr_handler; 35 - extern struct xattr_handler jffs2_acl_default_xattr_handler; 34 + extern const struct xattr_handler jffs2_acl_access_xattr_handler; 35 + extern const struct xattr_handler jffs2_acl_default_xattr_handler; 36 36 37 37 #else 38 38
+1 -1
fs/jffs2/security.c
··· 77 77 return retlen; 78 78 } 79 79 80 - struct xattr_handler jffs2_security_xattr_handler = { 80 + const struct xattr_handler jffs2_security_xattr_handler = { 81 81 .prefix = XATTR_SECURITY_PREFIX, 82 82 .list = jffs2_security_listxattr, 83 83 .set = jffs2_security_setxattr,
+4 -4
fs/jffs2/xattr.c
··· 904 904 * do_jffs2_setxattr(inode, xprefix, xname, buffer, size, flags) 905 905 * is an implementation of setxattr handler on jffs2. 906 906 * -------------------------------------------------- */ 907 - struct xattr_handler *jffs2_xattr_handlers[] = { 907 + const struct xattr_handler *jffs2_xattr_handlers[] = { 908 908 &jffs2_user_xattr_handler, 909 909 #ifdef CONFIG_JFFS2_FS_SECURITY 910 910 &jffs2_security_xattr_handler, ··· 917 917 NULL 918 918 }; 919 919 920 - static struct xattr_handler *xprefix_to_handler(int xprefix) { 921 - struct xattr_handler *ret; 920 + static const struct xattr_handler *xprefix_to_handler(int xprefix) { 921 + const struct xattr_handler *ret; 922 922 923 923 switch (xprefix) { 924 924 case JFFS2_XPREFIX_USER: ··· 955 955 struct jffs2_inode_cache *ic = f->inocache; 956 956 struct jffs2_xattr_ref *ref, **pref; 957 957 struct jffs2_xattr_datum *xd; 958 - struct xattr_handler *xhandle; 958 + const struct xattr_handler *xhandle; 959 959 ssize_t len, rc; 960 960 int retry = 0; 961 961
+4 -4
fs/jffs2/xattr.h
··· 93 93 extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname, 94 94 const char *buffer, size_t size, int flags); 95 95 96 - extern struct xattr_handler *jffs2_xattr_handlers[]; 97 - extern struct xattr_handler jffs2_user_xattr_handler; 98 - extern struct xattr_handler jffs2_trusted_xattr_handler; 96 + extern const struct xattr_handler *jffs2_xattr_handlers[]; 97 + extern const struct xattr_handler jffs2_user_xattr_handler; 98 + extern const struct xattr_handler jffs2_trusted_xattr_handler; 99 99 100 100 extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); 101 101 #define jffs2_getxattr generic_getxattr ··· 122 122 123 123 #ifdef CONFIG_JFFS2_FS_SECURITY 124 124 extern int jffs2_init_security(struct inode *inode, struct inode *dir); 125 - extern struct xattr_handler jffs2_security_xattr_handler; 125 + extern const struct xattr_handler jffs2_security_xattr_handler; 126 126 #else 127 127 #define jffs2_init_security(inode,dir) (0) 128 128 #endif /* CONFIG_JFFS2_FS_SECURITY */
+1 -1
fs/jffs2/xattr_trusted.c
··· 47 47 return retlen; 48 48 } 49 49 50 - struct xattr_handler jffs2_trusted_xattr_handler = { 50 + const struct xattr_handler jffs2_trusted_xattr_handler = { 51 51 .prefix = XATTR_TRUSTED_PREFIX, 52 52 .list = jffs2_trusted_listxattr, 53 53 .set = jffs2_trusted_setxattr,
+1 -1
fs/jffs2/xattr_user.c
··· 47 47 return retlen; 48 48 } 49 49 50 - struct xattr_handler jffs2_user_xattr_handler = { 50 + const struct xattr_handler jffs2_user_xattr_handler = { 51 51 .prefix = XATTR_USER_PREFIX, 52 52 .list = jffs2_user_listxattr, 53 53 .set = jffs2_user_setxattr,
+2 -10
fs/jfs/jfs_inode.c
··· 98 98 goto fail_unlock; 99 99 } 100 100 101 - inode->i_uid = current_fsuid(); 102 - if (parent->i_mode & S_ISGID) { 103 - inode->i_gid = parent->i_gid; 104 - if (S_ISDIR(mode)) 105 - mode |= S_ISGID; 106 - } else 107 - inode->i_gid = current_fsgid(); 108 - 101 + inode_init_owner(inode, parent, mode); 109 102 /* 110 103 * New inodes need to save sane values on disk when 111 104 * uid & gid mount options are used ··· 114 121 if (rc) 115 122 goto fail_drop; 116 123 117 - inode->i_mode = mode; 118 124 /* inherit flags from parent */ 119 125 jfs_inode->mode2 = JFS_IP(parent)->mode2 & JFS_FL_INHERIT; 120 126 ··· 126 134 if (S_ISLNK(mode)) 127 135 jfs_inode->mode2 &= ~(JFS_IMMUTABLE_FL|JFS_APPEND_FL); 128 136 } 129 - jfs_inode->mode2 |= mode; 137 + jfs_inode->mode2 |= inode->i_mode; 130 138 131 139 inode->i_blocks = 0; 132 140 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+1 -8
fs/logfs/inode.c
··· 358 358 inode->i_mode = mode; 359 359 logfs_set_ino_generation(sb, inode); 360 360 361 - inode->i_uid = current_fsuid(); 362 - inode->i_gid = current_fsgid(); 363 - if (dir->i_mode & S_ISGID) { 364 - inode->i_gid = dir->i_gid; 365 - if (S_ISDIR(mode)) 366 - inode->i_mode |= S_ISGID; 367 - } 368 - 361 + inode_init_owner(inode, dir, mode); 369 362 logfs_inode_setops(inode); 370 363 insert_inode_hash(inode); 371 364
+2 -3
fs/minix/bitmap.c
··· 221 221 clear_inode(inode); /* clear in-memory copy */ 222 222 } 223 223 224 - struct inode * minix_new_inode(const struct inode * dir, int * error) 224 + struct inode *minix_new_inode(const struct inode *dir, int mode, int *error) 225 225 { 226 226 struct super_block *sb = dir->i_sb; 227 227 struct minix_sb_info *sbi = minix_sb(sb); ··· 263 263 iput(inode); 264 264 return NULL; 265 265 } 266 - inode->i_uid = current_fsuid(); 267 - inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current_fsgid(); 266 + inode_init_owner(inode, dir, mode); 268 267 inode->i_ino = j; 269 268 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 270 269 inode->i_blocks = 0;
+1 -1
fs/minix/minix.h
··· 46 46 extern struct inode *minix_iget(struct super_block *, unsigned long); 47 47 extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); 48 48 extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); 49 - extern struct inode * minix_new_inode(const struct inode * dir, int * error); 49 + extern struct inode * minix_new_inode(const struct inode *, int, int *); 50 50 extern void minix_free_inode(struct inode * inode); 51 51 extern unsigned long minix_count_free_inodes(struct minix_sb_info *sbi); 52 52 extern int minix_new_block(struct inode * inode);
+3 -8
fs/minix/namei.c
··· 46 46 if (!old_valid_dev(rdev)) 47 47 return -EINVAL; 48 48 49 - inode = minix_new_inode(dir, &error); 49 + inode = minix_new_inode(dir, mode, &error); 50 50 51 51 if (inode) { 52 - inode->i_mode = mode; 53 52 minix_set_inode(inode, rdev); 54 53 mark_inode_dirty(inode); 55 54 error = add_nondir(dentry, inode); ··· 72 73 if (i > dir->i_sb->s_blocksize) 73 74 goto out; 74 75 75 - inode = minix_new_inode(dir, &err); 76 + inode = minix_new_inode(dir, S_IFLNK | 0777, &err); 76 77 if (!inode) 77 78 goto out; 78 79 79 - inode->i_mode = S_IFLNK | 0777; 80 80 minix_set_inode(inode, 0); 81 81 err = page_symlink(inode, symname, i); 82 82 if (err) ··· 115 117 116 118 inode_inc_link_count(dir); 117 119 118 - inode = minix_new_inode(dir, &err); 120 + inode = minix_new_inode(dir, mode, &err); 119 121 if (!inode) 120 122 goto out_dir; 121 123 122 - inode->i_mode = S_IFDIR | mode; 123 - if (dir->i_mode & S_ISGID) 124 - inode->i_mode |= S_ISGID; 125 124 minix_set_inode(inode, 0); 126 125 127 126 inode_inc_link_count(inode);
+3 -2
fs/namei.c
··· 523 523 static inline void path_to_nameidata(struct path *path, struct nameidata *nd) 524 524 { 525 525 dput(nd->path.dentry); 526 - if (nd->path.mnt != path->mnt) 526 + if (nd->path.mnt != path->mnt) { 527 527 mntput(nd->path.mnt); 528 - nd->path.mnt = path->mnt; 528 + nd->path.mnt = path->mnt; 529 + } 529 530 nd->path.dentry = path->dentry; 530 531 } 531 532
+42 -45
fs/nfsd/nfs4recover.c
··· 44 44 #define NFSDDBG_FACILITY NFSDDBG_PROC 45 45 46 46 /* Globals */ 47 - static struct path rec_dir; 48 - static int rec_dir_init = 0; 47 + static struct file *rec_file; 49 48 50 49 static int 51 50 nfs4_save_creds(const struct cred **original_creds) ··· 116 117 return status; 117 118 } 118 119 119 - static void 120 - nfsd4_sync_rec_dir(void) 121 - { 122 - vfs_fsync(NULL, rec_dir.dentry, 0); 123 - } 124 - 125 120 int 126 121 nfsd4_create_clid_dir(struct nfs4_client *clp) 127 122 { 128 123 const struct cred *original_cred; 129 124 char *dname = clp->cl_recdir; 130 - struct dentry *dentry; 125 + struct dentry *dir, *dentry; 131 126 int status; 132 127 133 128 dprintk("NFSD: nfsd4_create_clid_dir for \"%s\"\n", dname); 134 129 135 - if (!rec_dir_init || clp->cl_firststate) 130 + if (!rec_file || clp->cl_firststate) 136 131 return 0; 137 132 138 133 status = nfs4_save_creds(&original_cred); 139 134 if (status < 0) 140 135 return status; 141 136 137 + dir = rec_file->f_path.dentry; 142 138 /* lock the parent */ 143 - mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 139 + mutex_lock(&dir->d_inode->i_mutex); 144 140 145 - dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); 141 + dentry = lookup_one_len(dname, dir, HEXDIR_LEN-1); 146 142 if (IS_ERR(dentry)) { 147 143 status = PTR_ERR(dentry); 148 144 goto out_unlock; ··· 147 153 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); 148 154 goto out_put; 149 155 } 150 - status = mnt_want_write(rec_dir.mnt); 156 + status = mnt_want_write(rec_file->f_path.mnt); 151 157 if (status) 152 158 goto out_put; 153 - status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU); 154 - mnt_drop_write(rec_dir.mnt); 159 + status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU); 160 + mnt_drop_write(rec_file->f_path.mnt); 155 161 out_put: 156 162 dput(dentry); 157 163 out_unlock: 158 - mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 164 + mutex_unlock(&dir->d_inode->i_mutex); 159 165 if (status == 0) { 160 166 clp->cl_firststate = 1; 161 - nfsd4_sync_rec_dir(); 167 + vfs_fsync(rec_file, 0); 162 168 } 163 169 nfs4_reset_creds(original_cred); 164 170 dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status); ··· 200 206 struct dentry *dentry; 201 207 int status; 202 208 203 - if (!rec_dir_init) 209 + if (!rec_file) 204 210 return 0; 205 211 206 212 status = nfs4_save_creds(&original_cred); 207 213 if (status < 0) 208 214 return status; 209 215 210 - filp = dentry_open(dget(dir), mntget(rec_dir.mnt), O_RDONLY, 216 + filp = dentry_open(dget(dir), mntget(rec_file->f_path.mnt), O_RDONLY, 211 217 current_cred()); 212 218 status = PTR_ERR(filp); 213 219 if (IS_ERR(filp)) ··· 244 250 static int 245 251 nfsd4_unlink_clid_dir(char *name, int namlen) 246 252 { 247 - struct dentry *dentry; 253 + struct dentry *dir, *dentry; 248 254 int status; 249 255 250 256 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); 251 257 252 - mutex_lock_nested(&rec_dir.dentry->d_inode->i_mutex, I_MUTEX_PARENT); 253 - dentry = lookup_one_len(name, rec_dir.dentry, namlen); 258 + dir = rec_file->f_path.dentry; 259 + mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 260 + dentry = lookup_one_len(name, dir, namlen); 254 261 if (IS_ERR(dentry)) { 255 262 status = PTR_ERR(dentry); 256 263 goto out_unlock; ··· 259 264 status = -ENOENT; 260 265 if (!dentry->d_inode) 261 266 goto out; 262 - status = vfs_rmdir(rec_dir.dentry->d_inode, dentry); 267 + status = vfs_rmdir(dir->d_inode, dentry); 263 268 out: 264 269 dput(dentry); 265 270 out_unlock: 266 - mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 271 + mutex_unlock(&dir->d_inode->i_mutex); 267 272 return status; 268 273 } 269 274 ··· 273 278 const struct cred *original_cred; 274 279 int status; 275 280 276 - if (!rec_dir_init || !clp->cl_firststate) 281 + if (!rec_file || !clp->cl_firststate) 277 282 return; 278 283 279 - status = mnt_want_write(rec_dir.mnt); 284 + status = mnt_want_write(rec_file->f_path.mnt); 280 285 if (status) 281 286 goto out; 282 287 clp->cl_firststate = 0; ··· 288 293 status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1); 289 294 nfs4_reset_creds(original_cred); 290 295 if (status == 0) 291 - nfsd4_sync_rec_dir(); 292 - mnt_drop_write(rec_dir.mnt); 296 + vfs_fsync(rec_file, 0); 297 + mnt_drop_write(rec_file->f_path.mnt); 293 298 out: 294 299 if (status) 295 300 printk("NFSD: Failed to remove expired client state directory" ··· 318 323 nfsd4_recdir_purge_old(void) { 319 324 int status; 320 325 321 - if (!rec_dir_init) 326 + if (!rec_file) 322 327 return; 323 - status = mnt_want_write(rec_dir.mnt); 328 + status = mnt_want_write(rec_file->f_path.mnt); 324 329 if (status) 325 330 goto out; 326 - status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old); 331 + status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old); 327 332 if (status == 0) 328 - nfsd4_sync_rec_dir(); 329 - mnt_drop_write(rec_dir.mnt); 333 + vfs_fsync(rec_file, 0); 334 + mnt_drop_write(rec_file->f_path.mnt); 330 335 out: 331 336 if (status) 332 337 printk("nfsd4: failed to purge old clients from recovery" 333 - " directory %s\n", rec_dir.dentry->d_name.name); 338 + " directory %s\n", rec_file->f_path.dentry->d_name.name); 334 339 } 335 340 336 341 static int ··· 350 355 nfsd4_recdir_load(void) { 351 356 int status; 352 357 353 - status = nfsd4_list_rec_dir(rec_dir.dentry, load_recdir); 358 + if (!rec_file) 359 + return 0; 360 + 361 + status = nfsd4_list_rec_dir(rec_file->f_path.dentry, load_recdir); 354 362 if (status) 355 363 printk("nfsd4: failed loading clients from recovery" 356 - " directory %s\n", rec_dir.dentry->d_name.name); 364 + " directory %s\n", rec_file->f_path.dentry->d_name.name); 357 365 return status; 358 366 } 359 367 ··· 373 375 printk("NFSD: Using %s as the NFSv4 state recovery directory\n", 374 376 rec_dirname); 375 377 376 - BUG_ON(rec_dir_init); 378 + BUG_ON(rec_file); 377 379 378 380 status = nfs4_save_creds(&original_cred); 379 381 if (status < 0) { ··· 383 385 return; 384 386 } 385 387 386 - status = kern_path(rec_dirname, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, 387 - &rec_dir); 388 - if (status) 388 + rec_file = filp_open(rec_dirname, O_RDONLY | O_DIRECTORY, 0); 389 + if (IS_ERR(rec_file)) { 389 390 printk("NFSD: unable to find recovery directory %s\n", 390 391 rec_dirname); 392 + rec_file = NULL; 393 + } 391 394 392 - if (!status) 393 - rec_dir_init = 1; 394 395 nfs4_reset_creds(original_cred); 395 396 } 396 397 397 398 void 398 399 nfsd4_shutdown_recdir(void) 399 400 { 400 - if (!rec_dir_init) 401 + if (!rec_file) 401 402 return; 402 - rec_dir_init = 0; 403 - path_put(&rec_dir); 403 + fput(rec_file); 404 + rec_file = NULL; 404 405 }
+2 -3
fs/nfsd/vfs.c
··· 999 999 1000 1000 if (inode->i_state & I_DIRTY) { 1001 1001 dprintk("nfsd: write sync %d\n", task_pid_nr(current)); 1002 - err = vfs_fsync(file, file->f_path.dentry, 0); 1002 + err = vfs_fsync(file, 0); 1003 1003 } 1004 1004 last_ino = inode->i_ino; 1005 1005 last_dev = inode->i_sb->s_dev; ··· 1175 1175 if (err) 1176 1176 goto out; 1177 1177 if (EX_ISSYNC(fhp->fh_export)) { 1178 - int err2 = vfs_fsync_range(file, file->f_path.dentry, 1179 - offset, end, 0); 1178 + int err2 = vfs_fsync_range(file, offset, end, 0); 1180 1179 1181 1180 if (err2 != -EINVAL) 1182 1181 err = nfserrno(err2);
+1 -10
fs/nilfs2/inode.c
··· 280 280 /* reference count of i_bh inherits from nilfs_mdt_read_block() */ 281 281 282 282 atomic_inc(&sbi->s_inodes_count); 283 - 284 - inode->i_uid = current_fsuid(); 285 - if (dir->i_mode & S_ISGID) { 286 - inode->i_gid = dir->i_gid; 287 - if (S_ISDIR(mode)) 288 - mode |= S_ISGID; 289 - } else 290 - inode->i_gid = current_fsgid(); 291 - 292 - inode->i_mode = mode; 283 + inode_init_owner(inode, dir, mode); 293 284 inode->i_ino = ino; 294 285 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 295 286
+14 -74
fs/notify/inotify/inotify.c
··· 110 110 int pin_inotify_watch(struct inotify_watch *watch) 111 111 { 112 112 struct super_block *sb = watch->inode->i_sb; 113 - spin_lock(&sb_lock); 114 - if (sb->s_count >= S_BIAS) { 115 - atomic_inc(&sb->s_active); 116 - spin_unlock(&sb_lock); 113 + if (atomic_inc_not_zero(&sb->s_active)) { 117 114 atomic_inc(&watch->count); 118 115 return 1; 119 116 } 120 - spin_unlock(&sb_lock); 121 117 return 0; 122 118 } 123 119 ··· 511 515 * done. Cleanup is just deactivate_super(). However, that leaves a messy 512 516 * case - what if we *are* racing with umount() and active references to 513 517 * superblock can't be acquired anymore? We can bump ->s_count, grab 514 - * ->s_umount, which will almost certainly wait until the superblock is shut 515 - * down and the watch in question is pining for fjords. That's fine, but 516 - * there is a problem - we might have hit the window between ->s_active 517 - * getting to 0 / ->s_count - below S_BIAS (i.e. the moment when superblock 518 - * is past the point of no return and is heading for shutdown) and the 519 - * moment when deactivate_super() acquires ->s_umount. We could just do 520 - * drop_super() yield() and retry, but that's rather antisocial and this 521 - * stuff is luser-triggerable. OTOH, having grabbed ->s_umount and having 522 - * found that we'd got there first (i.e. that ->s_root is non-NULL) we know 523 - * that we won't race with inotify_umount_inodes(). So we could grab a 524 - * reference to watch and do the rest as above, just with drop_super() instead 525 - * of deactivate_super(), right? Wrong. We had to drop ih->mutex before we 526 - * could grab ->s_umount. So the watch could've been gone already. 527 - * 528 - * That still can be dealt with - we need to save watch->wd, do idr_find() 529 - * and compare its result with our pointer. If they match, we either have 530 - * the damn thing still alive or we'd lost not one but two races at once, 531 - * the watch had been killed and a new one got created with the same ->wd 532 - * at the same address. That couldn't have happened in inotify_destroy(), 533 - * but inotify_rm_wd() could run into that. Still, "new one got created" 534 - * is not a problem - we have every right to kill it or leave it alone, 535 - * whatever's more convenient. 536 - * 537 - * So we can use idr_find(...) == watch && watch->inode->i_sb == sb as 538 - * "grab it and kill it" check. If it's been our original watch, we are 539 - * fine, if it's a newcomer - nevermind, just pretend that we'd won the 540 - * race and kill the fscker anyway; we are safe since we know that its 541 - * superblock won't be going away. 518 + * ->s_umount, which will wait until the superblock is shut down and the 519 + * watch in question is pining for fjords. 542 520 * 543 521 * And yes, this is far beyond mere "not very pretty"; so's the entire 544 522 * concept of inotify to start with. ··· 526 556 * Called with ih->mutex held, drops it. Possible return values: 527 557 * 0 - nothing to do, it has died 528 558 * 1 - remove it, drop the reference and deactivate_super() 529 - * 2 - remove it, drop the reference and drop_super(); we tried hard to avoid 530 - * that variant, since it involved a lot of PITA, but that's the best that 531 - * could've been done. 532 559 */ 533 560 static int pin_to_kill(struct inotify_handle *ih, struct inotify_watch *watch) 534 561 { 535 562 struct super_block *sb = watch->inode->i_sb; 536 - s32 wd = watch->wd; 537 563 538 - spin_lock(&sb_lock); 539 - if (sb->s_count >= S_BIAS) { 540 - atomic_inc(&sb->s_active); 541 - spin_unlock(&sb_lock); 564 + if (atomic_inc_not_zero(&sb->s_active)) { 542 565 get_inotify_watch(watch); 543 566 mutex_unlock(&ih->mutex); 544 567 return 1; /* the best outcome */ 545 568 } 569 + spin_lock(&sb_lock); 546 570 sb->s_count++; 547 571 spin_unlock(&sb_lock); 548 572 mutex_unlock(&ih->mutex); /* can't grab ->s_umount under it */ 549 573 down_read(&sb->s_umount); 550 - if (likely(!sb->s_root)) { 551 - /* fs is already shut down; the watch is dead */ 552 - drop_super(sb); 553 - return 0; 554 - } 555 - /* raced with the final deactivate_super() */ 556 - mutex_lock(&ih->mutex); 557 - if (idr_find(&ih->idr, wd) != watch || watch->inode->i_sb != sb) { 558 - /* the watch is dead */ 559 - mutex_unlock(&ih->mutex); 560 - drop_super(sb); 561 - return 0; 562 - } 563 - /* still alive or freed and reused with the same sb and wd; kill */ 564 - get_inotify_watch(watch); 565 - mutex_unlock(&ih->mutex); 566 - return 2; 574 + /* fs is already shut down; the watch is dead */ 575 + drop_super(sb); 576 + return 0; 567 577 } 568 578 569 - static void unpin_and_kill(struct inotify_watch *watch, int how) 579 + static void unpin_and_kill(struct inotify_watch *watch) 570 580 { 571 581 struct super_block *sb = watch->inode->i_sb; 572 582 put_inotify_watch(watch); 573 - switch (how) { 574 - case 1: 575 - deactivate_super(sb); 576 - break; 577 - case 2: 578 - drop_super(sb); 579 - } 583 + deactivate_super(sb); 580 584 } 581 585 582 586 /** ··· 572 628 struct list_head *watches; 573 629 struct super_block *sb; 574 630 struct inode *inode; 575 - int how; 576 631 577 632 mutex_lock(&ih->mutex); 578 633 watches = &ih->watches; ··· 581 638 } 582 639 watch = list_first_entry(watches, struct inotify_watch, h_list); 583 640 sb = watch->inode->i_sb; 584 - how = pin_to_kill(ih, watch); 585 - if (!how) 641 + if (!pin_to_kill(ih, watch)) 586 642 continue; 587 643 588 644 inode = watch->inode; ··· 596 654 597 655 mutex_unlock(&ih->mutex); 598 656 mutex_unlock(&inode->inotify_mutex); 599 - unpin_and_kill(watch, how); 657 + unpin_and_kill(watch); 600 658 } 601 659 602 660 /* free this handle: the put matching the get in inotify_init() */ ··· 799 857 struct inotify_watch *watch; 800 858 struct super_block *sb; 801 859 struct inode *inode; 802 - int how; 803 860 804 861 mutex_lock(&ih->mutex); 805 862 watch = idr_find(&ih->idr, wd); ··· 807 866 return -EINVAL; 808 867 } 809 868 sb = watch->inode->i_sb; 810 - how = pin_to_kill(ih, watch); 811 - if (!how) 869 + if (!pin_to_kill(ih, watch)) 812 870 return 0; 813 871 814 872 inode = watch->inode; ··· 821 881 822 882 mutex_unlock(&ih->mutex); 823 883 mutex_unlock(&inode->inotify_mutex); 824 - unpin_and_kill(watch, how); 884 + unpin_and_kill(watch); 825 885 826 886 return 0; 827 887 }
+2 -2
fs/ocfs2/acl.c
··· 489 489 return ret; 490 490 } 491 491 492 - struct xattr_handler ocfs2_xattr_acl_access_handler = { 492 + const struct xattr_handler ocfs2_xattr_acl_access_handler = { 493 493 .prefix = POSIX_ACL_XATTR_ACCESS, 494 494 .flags = ACL_TYPE_ACCESS, 495 495 .list = ocfs2_xattr_list_acl_access, ··· 497 497 .set = ocfs2_xattr_set_acl, 498 498 }; 499 499 500 - struct xattr_handler ocfs2_xattr_acl_default_handler = { 500 + const struct xattr_handler ocfs2_xattr_acl_default_handler = { 501 501 .prefix = POSIX_ACL_XATTR_DEFAULT, 502 502 .flags = ACL_TYPE_DEFAULT, 503 503 .list = ocfs2_xattr_list_acl_default,
+1 -8
fs/ocfs2/namei.c
··· 204 204 inode->i_nlink = 2; 205 205 else 206 206 inode->i_nlink = 1; 207 - inode->i_uid = current_fsuid(); 208 - if (dir->i_mode & S_ISGID) { 209 - inode->i_gid = dir->i_gid; 210 - if (S_ISDIR(mode)) 211 - mode |= S_ISGID; 212 - } else 213 - inode->i_gid = current_fsgid(); 214 - inode->i_mode = mode; 207 + inode_init_owner(inode, dir, mode); 215 208 dquot_initialize(inode); 216 209 return inode; 217 210 }
+6 -6
fs/ocfs2/xattr.c
··· 97 97 .xv.xr_list.l_count = cpu_to_le16(1), 98 98 }; 99 99 100 - struct xattr_handler *ocfs2_xattr_handlers[] = { 100 + const struct xattr_handler *ocfs2_xattr_handlers[] = { 101 101 &ocfs2_xattr_user_handler, 102 102 &ocfs2_xattr_acl_access_handler, 103 103 &ocfs2_xattr_acl_default_handler, ··· 106 106 NULL 107 107 }; 108 108 109 - static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { 109 + static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { 110 110 [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, 111 111 [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] 112 112 = &ocfs2_xattr_acl_access_handler, ··· 540 540 541 541 static inline const char *ocfs2_xattr_prefix(int name_index) 542 542 { 543 - struct xattr_handler *handler = NULL; 543 + const struct xattr_handler *handler = NULL; 544 544 545 545 if (name_index > 0 && name_index < OCFS2_XATTR_MAX) 546 546 handler = ocfs2_xattr_handler_map[name_index]; ··· 7213 7213 xattr_ac, data_ac); 7214 7214 } 7215 7215 7216 - struct xattr_handler ocfs2_xattr_security_handler = { 7216 + const struct xattr_handler ocfs2_xattr_security_handler = { 7217 7217 .prefix = XATTR_SECURITY_PREFIX, 7218 7218 .list = ocfs2_xattr_security_list, 7219 7219 .get = ocfs2_xattr_security_get, ··· 7257 7257 name, value, size, flags); 7258 7258 } 7259 7259 7260 - struct xattr_handler ocfs2_xattr_trusted_handler = { 7260 + const struct xattr_handler ocfs2_xattr_trusted_handler = { 7261 7261 .prefix = XATTR_TRUSTED_PREFIX, 7262 7262 .list = ocfs2_xattr_trusted_list, 7263 7263 .get = ocfs2_xattr_trusted_get, ··· 7313 7313 name, value, size, flags); 7314 7314 } 7315 7315 7316 - struct xattr_handler ocfs2_xattr_user_handler = { 7316 + const struct xattr_handler ocfs2_xattr_user_handler = { 7317 7317 .prefix = XATTR_USER_PREFIX, 7318 7318 .list = ocfs2_xattr_user_list, 7319 7319 .get = ocfs2_xattr_user_get,
+6 -6
fs/ocfs2/xattr.h
··· 37 37 size_t value_len; 38 38 }; 39 39 40 - extern struct xattr_handler ocfs2_xattr_user_handler; 41 - extern struct xattr_handler ocfs2_xattr_trusted_handler; 42 - extern struct xattr_handler ocfs2_xattr_security_handler; 43 - extern struct xattr_handler ocfs2_xattr_acl_access_handler; 44 - extern struct xattr_handler ocfs2_xattr_acl_default_handler; 45 - extern struct xattr_handler *ocfs2_xattr_handlers[]; 40 + extern const struct xattr_handler ocfs2_xattr_user_handler; 41 + extern const struct xattr_handler ocfs2_xattr_trusted_handler; 42 + extern const struct xattr_handler ocfs2_xattr_security_handler; 43 + extern const struct xattr_handler ocfs2_xattr_acl_access_handler; 44 + extern const struct xattr_handler ocfs2_xattr_acl_default_handler; 45 + extern const struct xattr_handler *ocfs2_xattr_handlers[]; 46 46 47 47 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); 48 48 int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
+1 -3
fs/omfs/inode.c
··· 37 37 goto fail; 38 38 39 39 inode->i_ino = new_block; 40 - inode->i_mode = mode; 41 - inode->i_uid = current_fsuid(); 42 - inode->i_gid = current_fsgid(); 40 + inode_init_owner(inode, NULL, mode); 43 41 inode->i_mapping->a_ops = &omfs_aops; 44 42 45 43 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-166
fs/open.c
··· 17 17 #include <linux/securebits.h> 18 18 #include <linux/security.h> 19 19 #include <linux/mount.h> 20 - #include <linux/vfs.h> 21 20 #include <linux/fcntl.h> 22 21 #include <linux/slab.h> 23 22 #include <asm/uaccess.h> ··· 31 32 #include <linux/ima.h> 32 33 33 34 #include "internal.h" 34 - 35 - int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 36 - { 37 - int retval = -ENODEV; 38 - 39 - if (dentry) { 40 - retval = -ENOSYS; 41 - if (dentry->d_sb->s_op->statfs) { 42 - memset(buf, 0, sizeof(*buf)); 43 - retval = security_sb_statfs(dentry); 44 - if (retval) 45 - return retval; 46 - retval = dentry->d_sb->s_op->statfs(dentry, buf); 47 - if (retval == 0 && buf->f_frsize == 0) 48 - buf->f_frsize = buf->f_bsize; 49 - } 50 - } 51 - return retval; 52 - } 53 - 54 - EXPORT_SYMBOL(vfs_statfs); 55 - 56 - static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf) 57 - { 58 - struct kstatfs st; 59 - int retval; 60 - 61 - retval = vfs_statfs(dentry, &st); 62 - if (retval) 63 - return retval; 64 - 65 - if (sizeof(*buf) == sizeof(st)) 66 - memcpy(buf, &st, sizeof(st)); 67 - else { 68 - if (sizeof buf->f_blocks == 4) { 69 - if ((st.f_blocks | st.f_bfree | st.f_bavail | 70 - st.f_bsize | st.f_frsize) & 71 - 0xffffffff00000000ULL) 72 - return -EOVERFLOW; 73 - /* 74 - * f_files and f_ffree may be -1; it's okay to stuff 75 - * that into 32 bits 76 - */ 77 - if (st.f_files != -1 && 78 - (st.f_files & 0xffffffff00000000ULL)) 79 - return -EOVERFLOW; 80 - if (st.f_ffree != -1 && 81 - (st.f_ffree & 0xffffffff00000000ULL)) 82 - return -EOVERFLOW; 83 - } 84 - 85 - buf->f_type = st.f_type; 86 - buf->f_bsize = st.f_bsize; 87 - buf->f_blocks = st.f_blocks; 88 - buf->f_bfree = st.f_bfree; 89 - buf->f_bavail = st.f_bavail; 90 - buf->f_files = st.f_files; 91 - buf->f_ffree = st.f_ffree; 92 - buf->f_fsid = st.f_fsid; 93 - buf->f_namelen = st.f_namelen; 94 - buf->f_frsize = st.f_frsize; 95 - memset(buf->f_spare, 0, sizeof(buf->f_spare)); 96 - } 97 - return 0; 98 - } 99 - 100 - static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) 101 - { 102 - struct kstatfs st; 103 - int retval; 104 - 105 - retval = vfs_statfs(dentry, &st); 106 - if (retval) 107 - return retval; 108 - 109 - if (sizeof(*buf) == sizeof(st)) 110 - memcpy(buf, &st, sizeof(st)); 111 - else { 112 - buf->f_type = st.f_type; 113 - buf->f_bsize = st.f_bsize; 114 - buf->f_blocks = st.f_blocks; 115 - buf->f_bfree = st.f_bfree; 116 - buf->f_bavail = st.f_bavail; 117 - buf->f_files = st.f_files; 118 - buf->f_ffree = st.f_ffree; 119 - buf->f_fsid = st.f_fsid; 120 - buf->f_namelen = st.f_namelen; 121 - buf->f_frsize = st.f_frsize; 122 - memset(buf->f_spare, 0, sizeof(buf->f_spare)); 123 - } 124 - return 0; 125 - } 126 - 127 - SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, buf) 128 - { 129 - struct path path; 130 - int error; 131 - 132 - error = user_path(pathname, &path); 133 - if (!error) { 134 - struct statfs tmp; 135 - error = vfs_statfs_native(path.dentry, &tmp); 136 - if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 137 - error = -EFAULT; 138 - path_put(&path); 139 - } 140 - return error; 141 - } 142 - 143 - SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf) 144 - { 145 - struct path path; 146 - long error; 147 - 148 - if (sz != sizeof(*buf)) 149 - return -EINVAL; 150 - error = user_path(pathname, &path); 151 - if (!error) { 152 - struct statfs64 tmp; 153 - error = vfs_statfs64(path.dentry, &tmp); 154 - if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 155 - error = -EFAULT; 156 - path_put(&path); 157 - } 158 - return error; 159 - } 160 - 161 - SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf) 162 - { 163 - struct file * file; 164 - struct statfs tmp; 165 - int error; 166 - 167 - error = -EBADF; 168 - file = fget(fd); 169 - if (!file) 170 - goto out; 171 - error = vfs_statfs_native(file->f_path.dentry, &tmp); 172 - if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 173 - error = -EFAULT; 174 - fput(file); 175 - out: 176 - return error; 177 - } 178 - 179 - SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user *, buf) 180 - { 181 - struct file * file; 182 - struct statfs64 tmp; 183 - int error; 184 - 185 - if (sz != sizeof(*buf)) 186 - return -EINVAL; 187 - 188 - error = -EBADF; 189 - file = fget(fd); 190 - if (!file) 191 - goto out; 192 - error = vfs_statfs64(file->f_path.dentry, &tmp); 193 - if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 194 - error = -EFAULT; 195 - fput(file); 196 - out: 197 - return error; 198 - } 199 35 200 36 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, 201 37 struct file *filp)
+1 -1
fs/partitions/efi.c
··· 626 626 /* If this is a RAID volume, tell md */ 627 627 if (!efi_guidcmp(ptes[i].partition_type_guid, 628 628 PARTITION_LINUX_RAID_GUID)) 629 - state->parts[i+1].flags = 1; 629 + state->parts[i + 1].flags = ADDPART_FLAG_RAID; 630 630 } 631 631 kfree(ptes); 632 632 kfree(gpt);
+1 -1
fs/partitions/mac.c
··· 75 75 be32_to_cpu(part->block_count) * (secsize/512)); 76 76 77 77 if (!strnicmp(part->type, "Linux_RAID", 10)) 78 - state->parts[slot].flags = 1; 78 + state->parts[slot].flags = ADDPART_FLAG_RAID; 79 79 #ifdef CONFIG_PPC_PMAC 80 80 /* 81 81 * If this is the first bootable partition, tell the
+1 -1
fs/partitions/msdos.c
··· 498 498 } 499 499 put_partition(state, slot, start, size); 500 500 if (SYS_IND(p) == LINUX_RAID_PARTITION) 501 - state->parts[slot].flags = 1; 501 + state->parts[slot].flags = ADDPART_FLAG_RAID; 502 502 if (SYS_IND(p) == DM6_PARTITION) 503 503 printk("[DM]"); 504 504 if (SYS_IND(p) == EZD_PARTITION)
+9 -23
fs/quota/quota.c
··· 45 45 return security_quotactl(cmd, type, id, sb); 46 46 } 47 47 48 + static void quota_sync_one(struct super_block *sb, void *arg) 49 + { 50 + if (sb->s_qcop && sb->s_qcop->quota_sync) 51 + sb->s_qcop->quota_sync(sb, *(int *)arg, 1); 52 + } 53 + 48 54 static int quota_sync_all(int type) 49 55 { 50 - struct super_block *sb; 51 56 int ret; 52 57 53 58 if (type >= MAXQUOTAS) 54 59 return -EINVAL; 55 60 ret = security_quotactl(Q_SYNC, type, 0, NULL); 56 - if (ret) 57 - return ret; 58 - 59 - spin_lock(&sb_lock); 60 - restart: 61 - list_for_each_entry(sb, &super_blocks, s_list) { 62 - if (!sb->s_qcop || !sb->s_qcop->quota_sync) 63 - continue; 64 - 65 - sb->s_count++; 66 - spin_unlock(&sb_lock); 67 - down_read(&sb->s_umount); 68 - if (sb->s_root) 69 - sb->s_qcop->quota_sync(sb, type, 1); 70 - up_read(&sb->s_umount); 71 - spin_lock(&sb_lock); 72 - if (__put_super_and_need_restart(sb)) 73 - goto restart; 74 - } 75 - spin_unlock(&sb_lock); 76 - 77 - return 0; 61 + if (!ret) 62 + iterate_supers(quota_sync_one, &type); 63 + return ret; 78 64 } 79 65 80 66 static int quota_quotaon(struct super_block *sb, int type, int cmd, qid_t id,
+6 -14
fs/ramfs/inode.c
··· 52 52 BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP, 53 53 }; 54 54 55 - struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev) 55 + struct inode *ramfs_get_inode(struct super_block *sb, 56 + const struct inode *dir, int mode, dev_t dev) 56 57 { 57 58 struct inode * inode = new_inode(sb); 58 59 59 60 if (inode) { 60 - inode->i_mode = mode; 61 - inode->i_uid = current_fsuid(); 62 - inode->i_gid = current_fsgid(); 61 + inode_init_owner(inode, dir, mode); 63 62 inode->i_mapping->a_ops = &ramfs_aops; 64 63 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; 65 64 mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); ··· 94 95 static int 95 96 ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 96 97 { 97 - struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev); 98 + struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev); 98 99 int error = -ENOSPC; 99 100 100 101 if (inode) { 101 - if (dir->i_mode & S_ISGID) { 102 - inode->i_gid = dir->i_gid; 103 - if (S_ISDIR(mode)) 104 - inode->i_mode |= S_ISGID; 105 - } 106 102 d_instantiate(dentry, inode); 107 103 dget(dentry); /* Extra count - pin the dentry in core */ 108 104 error = 0; ··· 124 130 struct inode *inode; 125 131 int error = -ENOSPC; 126 132 127 - inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0); 133 + inode = ramfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0); 128 134 if (inode) { 129 135 int l = strlen(symname)+1; 130 136 error = page_symlink(inode, symname, l); 131 137 if (!error) { 132 - if (dir->i_mode & S_ISGID) 133 - inode->i_gid = dir->i_gid; 134 138 d_instantiate(dentry, inode); 135 139 dget(dentry); 136 140 dir->i_mtime = dir->i_ctime = CURRENT_TIME; ··· 233 241 sb->s_op = &ramfs_ops; 234 242 sb->s_time_gran = 1; 235 243 236 - inode = ramfs_get_inode(sb, S_IFDIR | fsi->mount_opts.mode, 0); 244 + inode = ramfs_get_inode(sb, NULL, S_IFDIR | fsi->mount_opts.mode, 0); 237 245 if (!inode) { 238 246 err = -ENOMEM; 239 247 goto fail;
+4 -14
fs/reiserfs/namei.c
··· 561 561 */ 562 562 static int new_inode_init(struct inode *inode, struct inode *dir, int mode) 563 563 { 564 - 565 - /* the quota init calls have to know who to charge the quota to, so 566 - ** we have to set uid and gid here 567 - */ 568 - inode->i_uid = current_fsuid(); 569 - inode->i_mode = mode; 570 564 /* Make inode invalid - just in case we are going to drop it before 571 565 * the initialization happens */ 572 566 INODE_PKEY(inode)->k_objectid = 0; 573 - 574 - if (dir->i_mode & S_ISGID) { 575 - inode->i_gid = dir->i_gid; 576 - if (S_ISDIR(mode)) 577 - inode->i_mode |= S_ISGID; 578 - } else { 579 - inode->i_gid = current_fsgid(); 580 - } 567 + /* the quota init calls have to know who to charge the quota to, so 568 + ** we have to set uid and gid here 569 + */ 570 + inode_init_owner(inode, dir, mode); 581 571 dquot_initialize(inode); 582 572 return 0; 583 573 }
+8 -8
fs/reiserfs/xattr.c
··· 723 723 (handler) = *(handlers)++) 724 724 725 725 /* This is the implementation for the xattr plugin infrastructure */ 726 - static inline struct xattr_handler * 727 - find_xattr_handler_prefix(struct xattr_handler **handlers, 726 + static inline const struct xattr_handler * 727 + find_xattr_handler_prefix(const struct xattr_handler **handlers, 728 728 const char *name) 729 729 { 730 - struct xattr_handler *xah; 730 + const struct xattr_handler *xah; 731 731 732 732 if (!handlers) 733 733 return NULL; ··· 748 748 reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, 749 749 size_t size) 750 750 { 751 - struct xattr_handler *handler; 751 + const struct xattr_handler *handler; 752 752 753 753 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 754 754 ··· 767 767 reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, 768 768 size_t size, int flags) 769 769 { 770 - struct xattr_handler *handler; 770 + const struct xattr_handler *handler; 771 771 772 772 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 773 773 ··· 784 784 */ 785 785 int reiserfs_removexattr(struct dentry *dentry, const char *name) 786 786 { 787 - struct xattr_handler *handler; 787 + const struct xattr_handler *handler; 788 788 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 789 789 790 790 if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) ··· 807 807 size_t size; 808 808 if (name[0] != '.' || 809 809 (namelen != 1 && (name[1] != '.' || namelen != 2))) { 810 - struct xattr_handler *handler; 810 + const struct xattr_handler *handler; 811 811 handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, 812 812 name); 813 813 if (!handler) /* Unsupported xattr name */ ··· 920 920 #endif 921 921 922 922 /* Actual operations that are exported to VFS-land */ 923 - struct xattr_handler *reiserfs_xattr_handlers[] = { 923 + const struct xattr_handler *reiserfs_xattr_handlers[] = { 924 924 #ifdef CONFIG_REISERFS_FS_XATTR 925 925 &reiserfs_xattr_user_handler, 926 926 &reiserfs_xattr_trusted_handler,
+2 -2
fs/reiserfs/xattr_acl.c
··· 500 500 return size; 501 501 } 502 502 503 - struct xattr_handler reiserfs_posix_acl_access_handler = { 503 + const struct xattr_handler reiserfs_posix_acl_access_handler = { 504 504 .prefix = POSIX_ACL_XATTR_ACCESS, 505 505 .flags = ACL_TYPE_ACCESS, 506 506 .get = posix_acl_get, ··· 520 520 return size; 521 521 } 522 522 523 - struct xattr_handler reiserfs_posix_acl_default_handler = { 523 + const struct xattr_handler reiserfs_posix_acl_default_handler = { 524 524 .prefix = POSIX_ACL_XATTR_DEFAULT, 525 525 .flags = ACL_TYPE_DEFAULT, 526 526 .get = posix_acl_get,
+1 -1
fs/reiserfs/xattr_security.c
··· 111 111 sec->value = NULL; 112 112 } 113 113 114 - struct xattr_handler reiserfs_xattr_security_handler = { 114 + const struct xattr_handler reiserfs_xattr_security_handler = { 115 115 .prefix = XATTR_SECURITY_PREFIX, 116 116 .get = security_get, 117 117 .set = security_set,
+1 -1
fs/reiserfs/xattr_trusted.c
··· 48 48 return len; 49 49 } 50 50 51 - struct xattr_handler reiserfs_xattr_trusted_handler = { 51 + const struct xattr_handler reiserfs_xattr_trusted_handler = { 52 52 .prefix = XATTR_TRUSTED_PREFIX, 53 53 .get = trusted_get, 54 54 .set = trusted_set,
+1 -1
fs/reiserfs/xattr_user.c
··· 44 44 return len; 45 45 } 46 46 47 - struct xattr_handler reiserfs_xattr_user_handler = { 47 + const struct xattr_handler reiserfs_xattr_user_handler = { 48 48 .prefix = XATTR_USER_PREFIX, 49 49 .get = user_get, 50 50 .set = user_set,
+196
fs/statfs.c
··· 1 + #include <linux/syscalls.h> 2 + #include <linux/module.h> 3 + #include <linux/fs.h> 4 + #include <linux/file.h> 5 + #include <linux/namei.h> 6 + #include <linux/statfs.h> 7 + #include <linux/security.h> 8 + #include <linux/uaccess.h> 9 + 10 + int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 11 + { 12 + int retval = -ENODEV; 13 + 14 + if (dentry) { 15 + retval = -ENOSYS; 16 + if (dentry->d_sb->s_op->statfs) { 17 + memset(buf, 0, sizeof(*buf)); 18 + retval = security_sb_statfs(dentry); 19 + if (retval) 20 + return retval; 21 + retval = dentry->d_sb->s_op->statfs(dentry, buf); 22 + if (retval == 0 && buf->f_frsize == 0) 23 + buf->f_frsize = buf->f_bsize; 24 + } 25 + } 26 + return retval; 27 + } 28 + 29 + EXPORT_SYMBOL(vfs_statfs); 30 + 31 + static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf) 32 + { 33 + struct kstatfs st; 34 + int retval; 35 + 36 + retval = vfs_statfs(dentry, &st); 37 + if (retval) 38 + return retval; 39 + 40 + if (sizeof(*buf) == sizeof(st)) 41 + memcpy(buf, &st, sizeof(st)); 42 + else { 43 + if (sizeof buf->f_blocks == 4) { 44 + if ((st.f_blocks | st.f_bfree | st.f_bavail | 45 + st.f_bsize | st.f_frsize) & 46 + 0xffffffff00000000ULL) 47 + return -EOVERFLOW; 48 + /* 49 + * f_files and f_ffree may be -1; it's okay to stuff 50 + * that into 32 bits 51 + */ 52 + if (st.f_files != -1 && 53 + (st.f_files & 0xffffffff00000000ULL)) 54 + return -EOVERFLOW; 55 + if (st.f_ffree != -1 && 56 + (st.f_ffree & 0xffffffff00000000ULL)) 57 + return -EOVERFLOW; 58 + } 59 + 60 + buf->f_type = st.f_type; 61 + buf->f_bsize = st.f_bsize; 62 + buf->f_blocks = st.f_blocks; 63 + buf->f_bfree = st.f_bfree; 64 + buf->f_bavail = st.f_bavail; 65 + buf->f_files = st.f_files; 66 + buf->f_ffree = st.f_ffree; 67 + buf->f_fsid = st.f_fsid; 68 + buf->f_namelen = st.f_namelen; 69 + buf->f_frsize = st.f_frsize; 70 + memset(buf->f_spare, 0, sizeof(buf->f_spare)); 71 + } 72 + return 0; 73 + } 74 + 75 + static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) 76 + { 77 + struct kstatfs st; 78 + int retval; 79 + 80 + retval = vfs_statfs(dentry, &st); 81 + if (retval) 82 + return retval; 83 + 84 + if (sizeof(*buf) == sizeof(st)) 85 + memcpy(buf, &st, sizeof(st)); 86 + else { 87 + buf->f_type = st.f_type; 88 + buf->f_bsize = st.f_bsize; 89 + buf->f_blocks = st.f_blocks; 90 + buf->f_bfree = st.f_bfree; 91 + buf->f_bavail = st.f_bavail; 92 + buf->f_files = st.f_files; 93 + buf->f_ffree = st.f_ffree; 94 + buf->f_fsid = st.f_fsid; 95 + buf->f_namelen = st.f_namelen; 96 + buf->f_frsize = st.f_frsize; 97 + memset(buf->f_spare, 0, sizeof(buf->f_spare)); 98 + } 99 + return 0; 100 + } 101 + 102 + SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, buf) 103 + { 104 + struct path path; 105 + int error; 106 + 107 + error = user_path(pathname, &path); 108 + if (!error) { 109 + struct statfs tmp; 110 + error = vfs_statfs_native(path.dentry, &tmp); 111 + if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 112 + error = -EFAULT; 113 + path_put(&path); 114 + } 115 + return error; 116 + } 117 + 118 + SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf) 119 + { 120 + struct path path; 121 + long error; 122 + 123 + if (sz != sizeof(*buf)) 124 + return -EINVAL; 125 + error = user_path(pathname, &path); 126 + if (!error) { 127 + struct statfs64 tmp; 128 + error = vfs_statfs64(path.dentry, &tmp); 129 + if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 130 + error = -EFAULT; 131 + path_put(&path); 132 + } 133 + return error; 134 + } 135 + 136 + SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf) 137 + { 138 + struct file *file; 139 + struct statfs tmp; 140 + int error; 141 + 142 + error = -EBADF; 143 + file = fget(fd); 144 + if (!file) 145 + goto out; 146 + error = vfs_statfs_native(file->f_path.dentry, &tmp); 147 + if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 148 + error = -EFAULT; 149 + fput(file); 150 + out: 151 + return error; 152 + } 153 + 154 + SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user *, buf) 155 + { 156 + struct file *file; 157 + struct statfs64 tmp; 158 + int error; 159 + 160 + if (sz != sizeof(*buf)) 161 + return -EINVAL; 162 + 163 + error = -EBADF; 164 + file = fget(fd); 165 + if (!file) 166 + goto out; 167 + error = vfs_statfs64(file->f_path.dentry, &tmp); 168 + if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 169 + error = -EFAULT; 170 + fput(file); 171 + out: 172 + return error; 173 + } 174 + 175 + SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) 176 + { 177 + struct super_block *s; 178 + struct ustat tmp; 179 + struct kstatfs sbuf; 180 + int err; 181 + 182 + s = user_get_super(new_decode_dev(dev)); 183 + if (!s) 184 + return -EINVAL; 185 + 186 + err = vfs_statfs(s->s_root, &sbuf); 187 + drop_super(s); 188 + if (err) 189 + return err; 190 + 191 + memset(&tmp,0,sizeof(struct ustat)); 192 + tmp.f_tfree = sbuf.f_bfree; 193 + tmp.f_tinode = sbuf.f_ffree; 194 + 195 + return copy_to_user(ubuf, &tmp, sizeof(struct ustat)) ? -EFAULT : 0; 196 + }
+189 -144
fs/super.c
··· 22 22 23 23 #include <linux/module.h> 24 24 #include <linux/slab.h> 25 - #include <linux/init.h> 26 - #include <linux/smp_lock.h> 27 25 #include <linux/acct.h> 28 26 #include <linux/blkdev.h> 29 27 #include <linux/quotaops.h> 30 - #include <linux/namei.h> 31 28 #include <linux/mount.h> 32 29 #include <linux/security.h> 33 - #include <linux/syscalls.h> 34 - #include <linux/vfs.h> 35 30 #include <linux/writeback.h> /* for the emergency remount stuff */ 36 31 #include <linux/idr.h> 37 - #include <linux/kobject.h> 38 32 #include <linux/mutex.h> 39 - #include <linux/file.h> 40 33 #include <linux/backing-dev.h> 41 - #include <asm/uaccess.h> 42 34 #include "internal.h" 43 35 44 36 ··· 85 93 * subclass. 86 94 */ 87 95 down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); 88 - s->s_count = S_BIAS; 96 + s->s_count = 1; 89 97 atomic_set(&s->s_active, 1); 90 98 mutex_init(&s->s_vfs_rename_mutex); 99 + lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key); 91 100 mutex_init(&s->s_dquot.dqio_mutex); 92 101 mutex_init(&s->s_dquot.dqonoff_mutex); 93 102 init_rwsem(&s->s_dquot.dqptr_sem); ··· 120 127 /* Superblock refcounting */ 121 128 122 129 /* 123 - * Drop a superblock's refcount. Returns non-zero if the superblock was 124 - * destroyed. The caller must hold sb_lock. 130 + * Drop a superblock's refcount. The caller must hold sb_lock. 125 131 */ 126 - static int __put_super(struct super_block *sb) 132 + void __put_super(struct super_block *sb) 127 133 { 128 - int ret = 0; 129 - 130 134 if (!--sb->s_count) { 135 + list_del_init(&sb->s_list); 131 136 destroy_super(sb); 132 - ret = 1; 133 137 } 134 - return ret; 135 - } 136 - 137 - /* 138 - * Drop a superblock's refcount. 139 - * Returns non-zero if the superblock is about to be destroyed and 140 - * at least is already removed from super_blocks list, so if we are 141 - * making a loop through super blocks then we need to restart. 142 - * The caller must hold sb_lock. 143 - */ 144 - int __put_super_and_need_restart(struct super_block *sb) 145 - { 146 - /* check for race with generic_shutdown_super() */ 147 - if (list_empty(&sb->s_list)) { 148 - /* super block is removed, need to restart... */ 149 - __put_super(sb); 150 - return 1; 151 - } 152 - /* can't be the last, since s_list is still in use */ 153 - sb->s_count--; 154 - BUG_ON(sb->s_count == 0); 155 - return 0; 156 138 } 157 139 158 140 /** ··· 146 178 147 179 148 180 /** 149 - * deactivate_super - drop an active reference to superblock 150 - * @s: superblock to deactivate 151 - * 152 - * Drops an active reference to superblock, acquiring a temprory one if 153 - * there is no active references left. In that case we lock superblock, 154 - * tell fs driver to shut it down and drop the temporary reference we 155 - * had just acquired. 156 - */ 157 - void deactivate_super(struct super_block *s) 158 - { 159 - struct file_system_type *fs = s->s_type; 160 - if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { 161 - s->s_count -= S_BIAS-1; 162 - spin_unlock(&sb_lock); 163 - vfs_dq_off(s, 0); 164 - down_write(&s->s_umount); 165 - fs->kill_sb(s); 166 - put_filesystem(fs); 167 - put_super(s); 168 - } 169 - } 170 - 171 - EXPORT_SYMBOL(deactivate_super); 172 - 173 - /** 174 181 * deactivate_locked_super - drop an active reference to superblock 175 182 * @s: superblock to deactivate 176 183 * 177 - * Equivalent of up_write(&s->s_umount); deactivate_super(s);, except that 178 - * it does not unlock it until it's all over. As the result, it's safe to 179 - * use to dispose of new superblock on ->get_sb() failure exits - nobody 180 - * will see the sucker until it's all over. Equivalent using up_write + 181 - * deactivate_super is safe for that purpose only if superblock is either 182 - * safe to use or has NULL ->s_root when we unlock. 184 + * Drops an active reference to superblock, converting it into a temprory 185 + * one if there is no other active references left. In that case we 186 + * tell fs driver to shut it down and drop the temporary reference we 187 + * had just acquired. 188 + * 189 + * Caller holds exclusive lock on superblock; that lock is released. 183 190 */ 184 191 void deactivate_locked_super(struct super_block *s) 185 192 { 186 193 struct file_system_type *fs = s->s_type; 187 - if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { 188 - s->s_count -= S_BIAS-1; 189 - spin_unlock(&sb_lock); 194 + if (atomic_dec_and_test(&s->s_active)) { 190 195 vfs_dq_off(s, 0); 191 196 fs->kill_sb(s); 192 197 put_filesystem(fs); ··· 170 229 } 171 230 172 231 EXPORT_SYMBOL(deactivate_locked_super); 232 + 233 + /** 234 + * deactivate_super - drop an active reference to superblock 235 + * @s: superblock to deactivate 236 + * 237 + * Variant of deactivate_locked_super(), except that superblock is *not* 238 + * locked by caller. If we are going to drop the final active reference, 239 + * lock will be acquired prior to that. 240 + */ 241 + void deactivate_super(struct super_block *s) 242 + { 243 + if (!atomic_add_unless(&s->s_active, -1, 1)) { 244 + down_write(&s->s_umount); 245 + deactivate_locked_super(s); 246 + } 247 + } 248 + 249 + EXPORT_SYMBOL(deactivate_super); 173 250 174 251 /** 175 252 * grab_super - acquire an active reference ··· 202 243 */ 203 244 static int grab_super(struct super_block *s) __releases(sb_lock) 204 245 { 246 + if (atomic_inc_not_zero(&s->s_active)) { 247 + spin_unlock(&sb_lock); 248 + return 1; 249 + } 250 + /* it's going away */ 205 251 s->s_count++; 206 252 spin_unlock(&sb_lock); 253 + /* wait for it to die */ 207 254 down_write(&s->s_umount); 208 - if (s->s_root) { 209 - spin_lock(&sb_lock); 210 - if (s->s_count > S_BIAS) { 211 - atomic_inc(&s->s_active); 212 - s->s_count--; 213 - spin_unlock(&sb_lock); 214 - return 1; 215 - } 216 - spin_unlock(&sb_lock); 217 - } 218 255 up_write(&s->s_umount); 219 256 put_super(s); 220 - yield(); 221 257 return 0; 222 258 } 223 259 ··· 275 321 } 276 322 spin_lock(&sb_lock); 277 323 /* should be initialized for __put_super_and_need_restart() */ 278 - list_del_init(&sb->s_list); 279 - list_del(&sb->s_instances); 324 + list_del_init(&sb->s_instances); 280 325 spin_unlock(&sb_lock); 281 326 up_write(&sb->s_umount); 282 327 } ··· 310 357 up_write(&s->s_umount); 311 358 destroy_super(s); 312 359 } 360 + down_write(&old->s_umount); 313 361 return old; 314 362 } 315 363 } ··· 362 408 */ 363 409 void sync_supers(void) 364 410 { 365 - struct super_block *sb; 411 + struct super_block *sb, *n; 366 412 367 413 spin_lock(&sb_lock); 368 - restart: 369 - list_for_each_entry(sb, &super_blocks, s_list) { 414 + list_for_each_entry_safe(sb, n, &super_blocks, s_list) { 415 + if (list_empty(&sb->s_instances)) 416 + continue; 370 417 if (sb->s_op->write_super && sb->s_dirt) { 371 418 sb->s_count++; 372 419 spin_unlock(&sb_lock); ··· 378 423 up_read(&sb->s_umount); 379 424 380 425 spin_lock(&sb_lock); 381 - if (__put_super_and_need_restart(sb)) 382 - goto restart; 426 + __put_super(sb); 383 427 } 428 + } 429 + spin_unlock(&sb_lock); 430 + } 431 + 432 + /** 433 + * iterate_supers - call function for all active superblocks 434 + * @f: function to call 435 + * @arg: argument to pass to it 436 + * 437 + * Scans the superblock list and calls given function, passing it 438 + * locked superblock and given argument. 439 + */ 440 + void iterate_supers(void (*f)(struct super_block *, void *), void *arg) 441 + { 442 + struct super_block *sb, *n; 443 + 444 + spin_lock(&sb_lock); 445 + list_for_each_entry_safe(sb, n, &super_blocks, s_list) { 446 + if (list_empty(&sb->s_instances)) 447 + continue; 448 + sb->s_count++; 449 + spin_unlock(&sb_lock); 450 + 451 + down_read(&sb->s_umount); 452 + if (sb->s_root) 453 + f(sb, arg); 454 + up_read(&sb->s_umount); 455 + 456 + spin_lock(&sb_lock); 457 + __put_super(sb); 384 458 } 385 459 spin_unlock(&sb_lock); 386 460 } ··· 422 438 * mounted on the device given. %NULL is returned if no match is found. 423 439 */ 424 440 425 - struct super_block * get_super(struct block_device *bdev) 441 + struct super_block *get_super(struct block_device *bdev) 426 442 { 427 443 struct super_block *sb; 428 444 ··· 432 448 spin_lock(&sb_lock); 433 449 rescan: 434 450 list_for_each_entry(sb, &super_blocks, s_list) { 451 + if (list_empty(&sb->s_instances)) 452 + continue; 435 453 if (sb->s_bdev == bdev) { 436 454 sb->s_count++; 437 455 spin_unlock(&sb_lock); 438 456 down_read(&sb->s_umount); 457 + /* still alive? */ 439 458 if (sb->s_root) 440 459 return sb; 441 460 up_read(&sb->s_umount); 442 - /* restart only when sb is no longer on the list */ 461 + /* nope, got unmounted */ 443 462 spin_lock(&sb_lock); 444 - if (__put_super_and_need_restart(sb)) 445 - goto rescan; 463 + __put_super(sb); 464 + goto rescan; 446 465 } 447 466 } 448 467 spin_unlock(&sb_lock); ··· 460 473 * 461 474 * Scans the superblock list and finds the superblock of the file system 462 475 * mounted on the device given. Returns the superblock with an active 463 - * reference and s_umount held exclusively or %NULL if none was found. 476 + * reference or %NULL if none was found. 464 477 */ 465 478 struct super_block *get_active_super(struct block_device *bdev) 466 479 { ··· 469 482 if (!bdev) 470 483 return NULL; 471 484 485 + restart: 472 486 spin_lock(&sb_lock); 473 487 list_for_each_entry(sb, &super_blocks, s_list) { 474 - if (sb->s_bdev != bdev) 488 + if (list_empty(&sb->s_instances)) 475 489 continue; 476 - 477 - sb->s_count++; 478 - spin_unlock(&sb_lock); 479 - down_write(&sb->s_umount); 480 - if (sb->s_root) { 481 - spin_lock(&sb_lock); 482 - if (sb->s_count > S_BIAS) { 483 - atomic_inc(&sb->s_active); 484 - sb->s_count--; 485 - spin_unlock(&sb_lock); 490 + if (sb->s_bdev == bdev) { 491 + if (grab_super(sb)) /* drops sb_lock */ 486 492 return sb; 487 - } 488 - spin_unlock(&sb_lock); 493 + else 494 + goto restart; 489 495 } 490 - up_write(&sb->s_umount); 491 - put_super(sb); 492 - yield(); 493 - spin_lock(&sb_lock); 494 496 } 495 497 spin_unlock(&sb_lock); 496 498 return NULL; 497 499 } 498 500 499 - struct super_block * user_get_super(dev_t dev) 501 + struct super_block *user_get_super(dev_t dev) 500 502 { 501 503 struct super_block *sb; 502 504 503 505 spin_lock(&sb_lock); 504 506 rescan: 505 507 list_for_each_entry(sb, &super_blocks, s_list) { 508 + if (list_empty(&sb->s_instances)) 509 + continue; 506 510 if (sb->s_dev == dev) { 507 511 sb->s_count++; 508 512 spin_unlock(&sb_lock); 509 513 down_read(&sb->s_umount); 514 + /* still alive? */ 510 515 if (sb->s_root) 511 516 return sb; 512 517 up_read(&sb->s_umount); 513 - /* restart only when sb is no longer on the list */ 518 + /* nope, got unmounted */ 514 519 spin_lock(&sb_lock); 515 - if (__put_super_and_need_restart(sb)) 516 - goto rescan; 520 + __put_super(sb); 521 + goto rescan; 517 522 } 518 523 } 519 524 spin_unlock(&sb_lock); 520 525 return NULL; 521 - } 522 - 523 - SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) 524 - { 525 - struct super_block *s; 526 - struct ustat tmp; 527 - struct kstatfs sbuf; 528 - int err = -EINVAL; 529 - 530 - s = user_get_super(new_decode_dev(dev)); 531 - if (s == NULL) 532 - goto out; 533 - err = vfs_statfs(s->s_root, &sbuf); 534 - drop_super(s); 535 - if (err) 536 - goto out; 537 - 538 - memset(&tmp,0,sizeof(struct ustat)); 539 - tmp.f_tfree = sbuf.f_bfree; 540 - tmp.f_tinode = sbuf.f_ffree; 541 - 542 - err = copy_to_user(ubuf,&tmp,sizeof(struct ustat)) ? -EFAULT : 0; 543 - out: 544 - return err; 545 526 } 546 527 547 528 /** ··· 577 622 578 623 static void do_emergency_remount(struct work_struct *work) 579 624 { 580 - struct super_block *sb; 625 + struct super_block *sb, *n; 581 626 582 627 spin_lock(&sb_lock); 583 - list_for_each_entry(sb, &super_blocks, s_list) { 628 + list_for_each_entry_safe(sb, n, &super_blocks, s_list) { 629 + if (list_empty(&sb->s_instances)) 630 + continue; 584 631 sb->s_count++; 585 632 spin_unlock(&sb_lock); 586 633 down_write(&sb->s_umount); 587 634 if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) { 588 635 /* 589 - * ->remount_fs needs lock_kernel(). 590 - * 591 636 * What lock protects sb->s_flags?? 592 637 */ 593 638 do_remount_sb(sb, MS_RDONLY, NULL, 1); 594 639 } 595 640 up_write(&sb->s_umount); 596 - put_super(sb); 597 641 spin_lock(&sb_lock); 642 + __put_super(sb); 598 643 } 599 644 spin_unlock(&sb_lock); 600 645 kfree(work); ··· 944 989 } 945 990 946 991 EXPORT_SYMBOL_GPL(vfs_kern_mount); 992 + 993 + /** 994 + * freeze_super -- lock the filesystem and force it into a consistent state 995 + * @super: the super to lock 996 + * 997 + * Syncs the super to make sure the filesystem is consistent and calls the fs's 998 + * freeze_fs. Subsequent calls to this without first thawing the fs will return 999 + * -EBUSY. 1000 + */ 1001 + int freeze_super(struct super_block *sb) 1002 + { 1003 + int ret; 1004 + 1005 + atomic_inc(&sb->s_active); 1006 + down_write(&sb->s_umount); 1007 + if (sb->s_frozen) { 1008 + deactivate_locked_super(sb); 1009 + return -EBUSY; 1010 + } 1011 + 1012 + if (sb->s_flags & MS_RDONLY) { 1013 + sb->s_frozen = SB_FREEZE_TRANS; 1014 + smp_wmb(); 1015 + up_write(&sb->s_umount); 1016 + return 0; 1017 + } 1018 + 1019 + sb->s_frozen = SB_FREEZE_WRITE; 1020 + smp_wmb(); 1021 + 1022 + sync_filesystem(sb); 1023 + 1024 + sb->s_frozen = SB_FREEZE_TRANS; 1025 + smp_wmb(); 1026 + 1027 + sync_blockdev(sb->s_bdev); 1028 + if (sb->s_op->freeze_fs) { 1029 + ret = sb->s_op->freeze_fs(sb); 1030 + if (ret) { 1031 + printk(KERN_ERR 1032 + "VFS:Filesystem freeze failed\n"); 1033 + sb->s_frozen = SB_UNFROZEN; 1034 + deactivate_locked_super(sb); 1035 + return ret; 1036 + } 1037 + } 1038 + up_write(&sb->s_umount); 1039 + return 0; 1040 + } 1041 + EXPORT_SYMBOL(freeze_super); 1042 + 1043 + /** 1044 + * thaw_super -- unlock filesystem 1045 + * @sb: the super to thaw 1046 + * 1047 + * Unlocks the filesystem and marks it writeable again after freeze_super(). 1048 + */ 1049 + int thaw_super(struct super_block *sb) 1050 + { 1051 + int error; 1052 + 1053 + down_write(&sb->s_umount); 1054 + if (sb->s_frozen == SB_UNFROZEN) { 1055 + up_write(&sb->s_umount); 1056 + return -EINVAL; 1057 + } 1058 + 1059 + if (sb->s_flags & MS_RDONLY) 1060 + goto out; 1061 + 1062 + if (sb->s_op->unfreeze_fs) { 1063 + error = sb->s_op->unfreeze_fs(sb); 1064 + if (error) { 1065 + printk(KERN_ERR 1066 + "VFS:Filesystem thaw failed\n"); 1067 + sb->s_frozen = SB_FREEZE_TRANS; 1068 + up_write(&sb->s_umount); 1069 + return error; 1070 + } 1071 + } 1072 + 1073 + out: 1074 + sb->s_frozen = SB_UNFROZEN; 1075 + smp_wmb(); 1076 + wake_up(&sb->s_wait_unfrozen); 1077 + deactivate_locked_super(sb); 1078 + 1079 + return 0; 1080 + } 1081 + EXPORT_SYMBOL(thaw_super); 947 1082 948 1083 static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) 949 1084 {
+14 -72
fs/sync.c
··· 77 77 } 78 78 EXPORT_SYMBOL_GPL(sync_filesystem); 79 79 80 + static void sync_one_sb(struct super_block *sb, void *arg) 81 + { 82 + if (!(sb->s_flags & MS_RDONLY) && sb->s_bdi) 83 + __sync_filesystem(sb, *(int *)arg); 84 + } 80 85 /* 81 86 * Sync all the data for all the filesystems (called by sys_sync() and 82 87 * emergency sync) 83 - * 84 - * This operation is careful to avoid the livelock which could easily happen 85 - * if two or more filesystems are being continuously dirtied. s_need_sync 86 - * is used only here. We set it against all filesystems and then clear it as 87 - * we sync them. So redirtied filesystems are skipped. 88 - * 89 - * But if process A is currently running sync_filesystems and then process B 90 - * calls sync_filesystems as well, process B will set all the s_need_sync 91 - * flags again, which will cause process A to resync everything. Fix that with 92 - * a local mutex. 93 88 */ 94 89 static void sync_filesystems(int wait) 95 90 { 96 - struct super_block *sb; 97 - static DEFINE_MUTEX(mutex); 98 - 99 - mutex_lock(&mutex); /* Could be down_interruptible */ 100 - spin_lock(&sb_lock); 101 - list_for_each_entry(sb, &super_blocks, s_list) 102 - sb->s_need_sync = 1; 103 - 104 - restart: 105 - list_for_each_entry(sb, &super_blocks, s_list) { 106 - if (!sb->s_need_sync) 107 - continue; 108 - sb->s_need_sync = 0; 109 - sb->s_count++; 110 - spin_unlock(&sb_lock); 111 - 112 - down_read(&sb->s_umount); 113 - if (!(sb->s_flags & MS_RDONLY) && sb->s_root && sb->s_bdi) 114 - __sync_filesystem(sb, wait); 115 - up_read(&sb->s_umount); 116 - 117 - /* restart only when sb is no longer on the list */ 118 - spin_lock(&sb_lock); 119 - if (__put_super_and_need_restart(sb)) 120 - goto restart; 121 - } 122 - spin_unlock(&sb_lock); 123 - mutex_unlock(&mutex); 91 + iterate_supers(sync_one_sb, &wait); 124 92 } 125 93 126 94 /* ··· 158 190 /** 159 191 * vfs_fsync_range - helper to sync a range of data & metadata to disk 160 192 * @file: file to sync 161 - * @dentry: dentry of @file 162 193 * @start: offset in bytes of the beginning of data range to sync 163 194 * @end: offset in bytes of the end of data range (inclusive) 164 195 * @datasync: perform only datasync ··· 165 198 * Write back data in range @start..@end and metadata for @file to disk. If 166 199 * @datasync is set only metadata needed to access modified file data is 167 200 * written. 168 - * 169 - * In case this function is called from nfsd @file may be %NULL and 170 - * only @dentry is set. This can only happen when the filesystem 171 - * implements the export_operations API. 172 201 */ 173 - int vfs_fsync_range(struct file *file, struct dentry *dentry, loff_t start, 174 - loff_t end, int datasync) 202 + int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) 175 203 { 176 - const struct file_operations *fop; 177 - struct address_space *mapping; 204 + struct address_space *mapping = file->f_mapping; 178 205 int err, ret; 179 206 180 - /* 181 - * Get mapping and operations from the file in case we have 182 - * as file, or get the default values for them in case we 183 - * don't have a struct file available. Damn nfsd.. 184 - */ 185 - if (file) { 186 - mapping = file->f_mapping; 187 - fop = file->f_op; 188 - } else { 189 - mapping = dentry->d_inode->i_mapping; 190 - fop = dentry->d_inode->i_fop; 191 - } 192 - 193 - if (!fop || !fop->fsync) { 207 + if (!file->f_op || !file->f_op->fsync) { 194 208 ret = -EINVAL; 195 209 goto out; 196 210 } ··· 183 235 * livelocks in fsync_buffers_list(). 184 236 */ 185 237 mutex_lock(&mapping->host->i_mutex); 186 - err = fop->fsync(file, dentry, datasync); 238 + err = file->f_op->fsync(file, file->f_path.dentry, datasync); 187 239 if (!ret) 188 240 ret = err; 189 241 mutex_unlock(&mapping->host->i_mutex); ··· 196 248 /** 197 249 * vfs_fsync - perform a fsync or fdatasync on a file 198 250 * @file: file to sync 199 - * @dentry: dentry of @file 200 251 * @datasync: only perform a fdatasync operation 201 252 * 202 253 * Write back data and metadata for @file to disk. If @datasync is 203 254 * set only metadata needed to access modified file data is written. 204 - * 205 - * In case this function is called from nfsd @file may be %NULL and 206 - * only @dentry is set. This can only happen when the filesystem 207 - * implements the export_operations API. 208 255 */ 209 - int vfs_fsync(struct file *file, struct dentry *dentry, int datasync) 256 + int vfs_fsync(struct file *file, int datasync) 210 257 { 211 - return vfs_fsync_range(file, dentry, 0, LLONG_MAX, datasync); 258 + return vfs_fsync_range(file, 0, LLONG_MAX, datasync); 212 259 } 213 260 EXPORT_SYMBOL(vfs_fsync); 214 261 ··· 214 271 215 272 file = fget(fd); 216 273 if (file) { 217 - ret = vfs_fsync(file, file->f_path.dentry, datasync); 274 + ret = vfs_fsync(file, datasync); 218 275 fput(file); 219 276 } 220 277 return ret; ··· 242 299 { 243 300 if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) 244 301 return 0; 245 - return vfs_fsync_range(file, file->f_path.dentry, pos, 246 - pos + count - 1, 302 + return vfs_fsync_range(file, pos, pos + count - 1, 247 303 (file->f_flags & __O_SYNC) ? 0 : 1); 248 304 } 249 305 EXPORT_SYMBOL(generic_write_sync);
+1 -10
fs/sysv/ialloc.c
··· 159 159 *sbi->s_sb_fic_count = cpu_to_fs16(sbi, count); 160 160 fs16_add(sbi, sbi->s_sb_total_free_inodes, -1); 161 161 dirty_sb(sb); 162 - 163 - if (dir->i_mode & S_ISGID) { 164 - inode->i_gid = dir->i_gid; 165 - if (S_ISDIR(mode)) 166 - mode |= S_ISGID; 167 - } else 168 - inode->i_gid = current_fsgid(); 169 - 170 - inode->i_uid = current_fsuid(); 162 + inode_init_owner(inode, dir, mode); 171 163 inode->i_ino = fs16_to_cpu(sbi, ino); 172 164 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 173 165 inode->i_blocks = 0; ··· 168 176 insert_inode_hash(inode); 169 177 mark_inode_dirty(inode); 170 178 171 - inode->i_mode = mode; /* for sysv_write_inode() */ 172 179 sysv_write_inode(inode, 0); /* ensure inode not allocated again */ 173 180 mark_inode_dirty(inode); /* cleared by sysv_write_inode() */ 174 181 /* That's it. */
+1 -8
fs/ubifs/dir.c
··· 104 104 */ 105 105 inode->i_flags |= (S_NOCMTIME); 106 106 107 - inode->i_uid = current_fsuid(); 108 - if (dir->i_mode & S_ISGID) { 109 - inode->i_gid = dir->i_gid; 110 - if (S_ISDIR(mode)) 111 - mode |= S_ISGID; 112 - } else 113 - inode->i_gid = current_fsgid(); 114 - inode->i_mode = mode; 107 + inode_init_owner(inode, dir, mode); 115 108 inode->i_mtime = inode->i_atime = inode->i_ctime = 116 109 ubifs_current_time(inode); 117 110 inode->i_mapping->nrpages = 0;
+2 -9
fs/udf/ialloc.c
··· 124 124 udf_updated_lvid(sb); 125 125 } 126 126 mutex_unlock(&sbi->s_alloc_mutex); 127 - inode->i_mode = mode; 128 - inode->i_uid = current_fsuid(); 129 - if (dir->i_mode & S_ISGID) { 130 - inode->i_gid = dir->i_gid; 131 - if (S_ISDIR(mode)) 132 - mode |= S_ISGID; 133 - } else { 134 - inode->i_gid = current_fsgid(); 135 - } 127 + 128 + inode_init_owner(inode, dir, mode); 136 129 137 130 iinfo->i_location.logicalBlockNum = block; 138 131 iinfo->i_location.partitionReferenceNum =
+2 -8
fs/udf/namei.c
··· 579 579 inode->i_data.a_ops = &udf_aops; 580 580 inode->i_op = &udf_file_inode_operations; 581 581 inode->i_fop = &udf_file_operations; 582 - inode->i_mode = mode; 583 582 mark_inode_dirty(inode); 584 583 585 584 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); ··· 626 627 goto out; 627 628 628 629 iinfo = UDF_I(inode); 629 - inode->i_uid = current_fsuid(); 630 630 init_special_inode(inode, mode, rdev); 631 631 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); 632 632 if (!fi) { ··· 672 674 goto out; 673 675 674 676 err = -EIO; 675 - inode = udf_new_inode(dir, S_IFDIR, &err); 677 + inode = udf_new_inode(dir, S_IFDIR | mode, &err); 676 678 if (!inode) 677 679 goto out; 678 680 ··· 695 697 FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; 696 698 udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); 697 699 brelse(fibh.sbh); 698 - inode->i_mode = S_IFDIR | mode; 699 - if (dir->i_mode & S_ISGID) 700 - inode->i_mode |= S_ISGID; 701 700 mark_inode_dirty(inode); 702 701 703 702 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); ··· 907 912 dquot_initialize(dir); 908 913 909 914 lock_kernel(); 910 - inode = udf_new_inode(dir, S_IFLNK, &err); 915 + inode = udf_new_inode(dir, S_IFLNK | S_IRWXUGO, &err); 911 916 if (!inode) 912 917 goto out; 913 918 ··· 918 923 } 919 924 920 925 iinfo = UDF_I(inode); 921 - inode->i_mode = S_IFLNK | S_IRWXUGO; 922 926 inode->i_data.a_ops = &udf_symlink_aops; 923 927 inode->i_op = &udf_symlink_inode_operations; 924 928
+1 -9
fs/ufs/ialloc.c
··· 303 303 sb->s_dirt = 1; 304 304 305 305 inode->i_ino = cg * uspi->s_ipg + bit; 306 - inode->i_mode = mode; 307 - inode->i_uid = current_fsuid(); 308 - if (dir->i_mode & S_ISGID) { 309 - inode->i_gid = dir->i_gid; 310 - if (S_ISDIR(mode)) 311 - inode->i_mode |= S_ISGID; 312 - } else 313 - inode->i_gid = current_fsgid(); 314 - 306 + inode_init_owner(inode, dir, mode); 315 307 inode->i_blocks = 0; 316 308 inode->i_generation = 0; 317 309 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+7 -7
fs/xattr.c
··· 590 590 /* 591 591 * Find the xattr_handler with the matching prefix. 592 592 */ 593 - static struct xattr_handler * 594 - xattr_resolve_name(struct xattr_handler **handlers, const char **name) 593 + static const struct xattr_handler * 594 + xattr_resolve_name(const struct xattr_handler **handlers, const char **name) 595 595 { 596 - struct xattr_handler *handler; 596 + const struct xattr_handler *handler; 597 597 598 598 if (!*name) 599 599 return NULL; ··· 614 614 ssize_t 615 615 generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) 616 616 { 617 - struct xattr_handler *handler; 617 + const struct xattr_handler *handler; 618 618 619 619 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 620 620 if (!handler) ··· 629 629 ssize_t 630 630 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 631 631 { 632 - struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; 632 + const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; 633 633 unsigned int size = 0; 634 634 635 635 if (!buffer) { ··· 659 659 int 660 660 generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 661 661 { 662 - struct xattr_handler *handler; 662 + const struct xattr_handler *handler; 663 663 664 664 if (size == 0) 665 665 value = ""; /* empty EA, do not remove */ ··· 676 676 int 677 677 generic_removexattr(struct dentry *dentry, const char *name) 678 678 { 679 - struct xattr_handler *handler; 679 + const struct xattr_handler *handler; 680 680 681 681 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 682 682 if (!handler)
+2 -2
fs/xfs/linux-2.6/xfs_acl.c
··· 440 440 return error; 441 441 } 442 442 443 - struct xattr_handler xfs_xattr_acl_access_handler = { 443 + const struct xattr_handler xfs_xattr_acl_access_handler = { 444 444 .prefix = POSIX_ACL_XATTR_ACCESS, 445 445 .flags = ACL_TYPE_ACCESS, 446 446 .get = xfs_xattr_acl_get, 447 447 .set = xfs_xattr_acl_set, 448 448 }; 449 449 450 - struct xattr_handler xfs_xattr_acl_default_handler = { 450 + const struct xattr_handler xfs_xattr_acl_default_handler = { 451 451 .prefix = POSIX_ACL_XATTR_DEFAULT, 452 452 .flags = ACL_TYPE_DEFAULT, 453 453 .get = xfs_xattr_acl_get,
+1 -1
fs/xfs/linux-2.6/xfs_super.h
··· 85 85 extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); 86 86 87 87 extern const struct export_operations xfs_export_operations; 88 - extern struct xattr_handler *xfs_xattr_handlers[]; 88 + extern const struct xattr_handler *xfs_xattr_handlers[]; 89 89 extern const struct quotactl_ops xfs_quotactl_operations; 90 90 91 91 #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info))
+4 -4
fs/xfs/linux-2.6/xfs_xattr.c
··· 72 72 (void *)value, size, xflags); 73 73 } 74 74 75 - static struct xattr_handler xfs_xattr_user_handler = { 75 + static const struct xattr_handler xfs_xattr_user_handler = { 76 76 .prefix = XATTR_USER_PREFIX, 77 77 .flags = 0, /* no flags implies user namespace */ 78 78 .get = xfs_xattr_get, 79 79 .set = xfs_xattr_set, 80 80 }; 81 81 82 - static struct xattr_handler xfs_xattr_trusted_handler = { 82 + static const struct xattr_handler xfs_xattr_trusted_handler = { 83 83 .prefix = XATTR_TRUSTED_PREFIX, 84 84 .flags = ATTR_ROOT, 85 85 .get = xfs_xattr_get, 86 86 .set = xfs_xattr_set, 87 87 }; 88 88 89 - static struct xattr_handler xfs_xattr_security_handler = { 89 + static const struct xattr_handler xfs_xattr_security_handler = { 90 90 .prefix = XATTR_SECURITY_PREFIX, 91 91 .flags = ATTR_SECURE, 92 92 .get = xfs_xattr_get, 93 93 .set = xfs_xattr_set, 94 94 }; 95 95 96 - struct xattr_handler *xfs_xattr_handlers[] = { 96 + const struct xattr_handler *xfs_xattr_handlers[] = { 97 97 &xfs_xattr_user_handler, 98 98 &xfs_xattr_trusted_handler, 99 99 &xfs_xattr_security_handler,
+2 -2
fs/xfs/xfs_acl.h
··· 49 49 extern int posix_acl_access_exists(struct inode *inode); 50 50 extern int posix_acl_default_exists(struct inode *inode); 51 51 52 - extern struct xattr_handler xfs_xattr_acl_access_handler; 53 - extern struct xattr_handler xfs_xattr_acl_default_handler; 52 + extern const struct xattr_handler xfs_xattr_acl_access_handler; 53 + extern const struct xattr_handler xfs_xattr_acl_default_handler; 54 54 #else 55 55 # define xfs_check_acl NULL 56 56 # define xfs_get_acl(inode, type) NULL
+10 -10
include/linux/fs.h
··· 1315 1315 extern struct list_head super_blocks; 1316 1316 extern spinlock_t sb_lock; 1317 1317 1318 - #define sb_entry(list) list_entry((list), struct super_block, s_list) 1319 - #define S_BIAS (1<<30) 1320 1318 struct super_block { 1321 1319 struct list_head s_list; /* Keep this first */ 1322 1320 dev_t s_dev; /* search index; _not_ kdev_t */ ··· 1333 1335 struct rw_semaphore s_umount; 1334 1336 struct mutex s_lock; 1335 1337 int s_count; 1336 - int s_need_sync; 1337 1338 atomic_t s_active; 1338 1339 #ifdef CONFIG_SECURITY 1339 1340 void *s_security; 1340 1341 #endif 1341 - struct xattr_handler **s_xattr; 1342 + const struct xattr_handler **s_xattr; 1342 1343 1343 1344 struct list_head s_inodes; /* all inodes */ 1344 1345 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ ··· 1429 1432 * VFS file helper functions. 1430 1433 */ 1431 1434 extern int file_permission(struct file *, int); 1432 - 1435 + extern void inode_init_owner(struct inode *inode, const struct inode *dir, 1436 + mode_t mode); 1433 1437 /* 1434 1438 * VFS FS_IOC_FIEMAP helper definitions. 1435 1439 */ ··· 1743 1745 1744 1746 struct lock_class_key s_lock_key; 1745 1747 struct lock_class_key s_umount_key; 1748 + struct lock_class_key s_vfs_rename_key; 1746 1749 1747 1750 struct lock_class_key i_lock_key; 1748 1751 struct lock_class_key i_mutex_key; ··· 1781 1782 const struct super_operations *ops, unsigned long, 1782 1783 struct vfsmount *mnt); 1783 1784 extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1784 - int __put_super_and_need_restart(struct super_block *sb); 1785 - void put_super(struct super_block *sb); 1786 1785 1787 1786 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1788 1787 #define fops_get(fops) \ ··· 1800 1803 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 1801 1804 struct vfsmount *); 1802 1805 extern int vfs_statfs(struct dentry *, struct kstatfs *); 1806 + extern int freeze_super(struct super_block *super); 1807 + extern int thaw_super(struct super_block *super); 1803 1808 1804 1809 extern int current_umask(void); 1805 1810 ··· 2087 2088 extern int filemap_fdatawrite_range(struct address_space *mapping, 2088 2089 loff_t start, loff_t end); 2089 2090 2090 - extern int vfs_fsync_range(struct file *file, struct dentry *dentry, 2091 - loff_t start, loff_t end, int datasync); 2092 - extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync); 2091 + extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, 2092 + int datasync); 2093 + extern int vfs_fsync(struct file *file, int datasync); 2093 2094 extern int generic_write_sync(struct file *file, loff_t pos, loff_t count); 2094 2095 extern void sync_supers(void); 2095 2096 extern void emergency_sync(void); ··· 2329 2330 extern struct super_block *get_active_super(struct block_device *bdev); 2330 2331 extern struct super_block *user_get_super(dev_t); 2331 2332 extern void drop_super(struct super_block *sb); 2333 + extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2332 2334 2333 2335 extern int dcache_dir_open(struct inode *, struct file *); 2334 2336 extern int dcache_dir_close(struct inode *, struct file *);
+2 -2
include/linux/generic_acl.h
··· 5 5 6 6 struct inode; 7 7 8 - extern struct xattr_handler generic_acl_access_handler; 9 - extern struct xattr_handler generic_acl_default_handler; 8 + extern const struct xattr_handler generic_acl_access_handler; 9 + extern const struct xattr_handler generic_acl_default_handler; 10 10 11 11 int generic_acl_init(struct inode *, struct inode *); 12 12 int generic_acl_chmod(struct inode *);
+2 -1
include/linux/ramfs.h
··· 1 1 #ifndef _LINUX_RAMFS_H 2 2 #define _LINUX_RAMFS_H 3 3 4 - struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev); 4 + struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, 5 + int mode, dev_t dev); 5 6 extern int ramfs_get_sb(struct file_system_type *fs_type, 6 7 int flags, const char *dev_name, void *data, struct vfsmount *mnt); 7 8
+2 -2
include/linux/reiserfs_acl.h
··· 53 53 struct inode *dir, struct dentry *dentry, 54 54 struct inode *inode); 55 55 int reiserfs_cache_default_acl(struct inode *dir); 56 - extern struct xattr_handler reiserfs_posix_acl_default_handler; 57 - extern struct xattr_handler reiserfs_posix_acl_access_handler; 56 + extern const struct xattr_handler reiserfs_posix_acl_default_handler; 57 + extern const struct xattr_handler reiserfs_posix_acl_access_handler; 58 58 59 59 #else 60 60
+3 -3
include/linux/reiserfs_xattr.h
··· 58 58 struct inode *, const char *, const void *, 59 59 size_t, int); 60 60 61 - extern struct xattr_handler reiserfs_xattr_user_handler; 62 - extern struct xattr_handler reiserfs_xattr_trusted_handler; 63 - extern struct xattr_handler reiserfs_xattr_security_handler; 61 + extern const struct xattr_handler reiserfs_xattr_user_handler; 62 + extern const struct xattr_handler reiserfs_xattr_trusted_handler; 63 + extern const struct xattr_handler reiserfs_xattr_security_handler; 64 64 #ifdef CONFIG_REISERFS_FS_SECURITY 65 65 int reiserfs_security_init(struct inode *dir, struct inode *inode, 66 66 struct reiserfs_security_handle *sec);
+1 -1
include/linux/xattr.h
··· 37 37 struct dentry; 38 38 39 39 struct xattr_handler { 40 - char *prefix; 40 + const char *prefix; 41 41 int flags; /* fs private flags passed back to the handlers */ 42 42 size_t (*list)(struct dentry *dentry, char *list, size_t list_size, 43 43 const char *name, size_t name_len, int handler_flags);
+1 -1
mm/msync.c
··· 82 82 (vma->vm_flags & VM_SHARED)) { 83 83 get_file(file); 84 84 up_read(&mm->mmap_sem); 85 - error = vfs_fsync(file, file->f_path.dentry, 0); 85 + error = vfs_fsync(file, 0); 86 86 fput(file); 87 87 if (error || start >= end) 88 88 goto out;
+10 -19
mm/shmem.c
··· 1545 1545 return 0; 1546 1546 } 1547 1547 1548 - static struct inode *shmem_get_inode(struct super_block *sb, int mode, 1549 - dev_t dev, unsigned long flags) 1548 + static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir, 1549 + int mode, dev_t dev, unsigned long flags) 1550 1550 { 1551 1551 struct inode *inode; 1552 1552 struct shmem_inode_info *info; ··· 1557 1557 1558 1558 inode = new_inode(sb); 1559 1559 if (inode) { 1560 - inode->i_mode = mode; 1561 - inode->i_uid = current_fsuid(); 1562 - inode->i_gid = current_fsgid(); 1560 + inode_init_owner(inode, dir, mode); 1563 1561 inode->i_blocks = 0; 1564 1562 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1565 1563 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; ··· 1812 1814 struct inode *inode; 1813 1815 int error = -ENOSPC; 1814 1816 1815 - inode = shmem_get_inode(dir->i_sb, mode, dev, VM_NORESERVE); 1817 + inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE); 1816 1818 if (inode) { 1817 1819 error = security_inode_init_security(inode, dir, NULL, NULL, 1818 1820 NULL); ··· 1831 1833 #else 1832 1834 error = 0; 1833 1835 #endif 1834 - if (dir->i_mode & S_ISGID) { 1835 - inode->i_gid = dir->i_gid; 1836 - if (S_ISDIR(mode)) 1837 - inode->i_mode |= S_ISGID; 1838 - } 1839 1836 dir->i_size += BOGO_DIRENT_SIZE; 1840 1837 dir->i_ctime = dir->i_mtime = CURRENT_TIME; 1841 1838 d_instantiate(dentry, inode); ··· 1950 1957 if (len > PAGE_CACHE_SIZE) 1951 1958 return -ENAMETOOLONG; 1952 1959 1953 - inode = shmem_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE); 1960 + inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE); 1954 1961 if (!inode) 1955 1962 return -ENOSPC; 1956 1963 ··· 1985 1992 unlock_page(page); 1986 1993 page_cache_release(page); 1987 1994 } 1988 - if (dir->i_mode & S_ISGID) 1989 - inode->i_gid = dir->i_gid; 1990 1995 dir->i_size += BOGO_DIRENT_SIZE; 1991 1996 dir->i_ctime = dir->i_mtime = CURRENT_TIME; 1992 1997 d_instantiate(dentry, inode); ··· 2062 2071 size, flags); 2063 2072 } 2064 2073 2065 - static struct xattr_handler shmem_xattr_security_handler = { 2074 + static const struct xattr_handler shmem_xattr_security_handler = { 2066 2075 .prefix = XATTR_SECURITY_PREFIX, 2067 2076 .list = shmem_xattr_security_list, 2068 2077 .get = shmem_xattr_security_get, 2069 2078 .set = shmem_xattr_security_set, 2070 2079 }; 2071 2080 2072 - static struct xattr_handler *shmem_xattr_handlers[] = { 2081 + static const struct xattr_handler *shmem_xattr_handlers[] = { 2073 2082 &generic_acl_access_handler, 2074 2083 &generic_acl_default_handler, 2075 2084 &shmem_xattr_security_handler, ··· 2357 2366 sb->s_flags |= MS_POSIXACL; 2358 2367 #endif 2359 2368 2360 - inode = shmem_get_inode(sb, S_IFDIR | sbinfo->mode, 0, VM_NORESERVE); 2369 + inode = shmem_get_inode(sb, NULL, S_IFDIR | sbinfo->mode, 0, VM_NORESERVE); 2361 2370 if (!inode) 2362 2371 goto failed; 2363 2372 inode->i_uid = sbinfo->uid; ··· 2602 2611 2603 2612 #define shmem_vm_ops generic_file_vm_ops 2604 2613 #define shmem_file_operations ramfs_file_operations 2605 - #define shmem_get_inode(sb, mode, dev, flags) ramfs_get_inode(sb, mode, dev) 2614 + #define shmem_get_inode(sb, dir, mode, dev, flags) ramfs_get_inode(sb, dir, mode, dev) 2606 2615 #define shmem_acct_size(flags, size) 0 2607 2616 #define shmem_unacct_size(flags, size) do {} while (0) 2608 2617 #define SHMEM_MAX_BYTES MAX_LFS_FILESIZE ··· 2646 2655 path.mnt = mntget(shm_mnt); 2647 2656 2648 2657 error = -ENOSPC; 2649 - inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); 2658 + inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); 2650 2659 if (!inode) 2651 2660 goto put_dentry; 2652 2661
+8 -47
security/selinux/hooks.c
··· 126 126 int selinux_enabled = 1; 127 127 #endif 128 128 129 - /* Lists of inode and superblock security structures initialized 130 - before the policy was loaded. */ 131 - static LIST_HEAD(superblock_security_head); 132 - static DEFINE_SPINLOCK(sb_security_lock); 133 - 134 129 static struct kmem_cache *sel_inode_cache; 135 130 136 131 /** ··· 261 266 return -ENOMEM; 262 267 263 268 mutex_init(&sbsec->lock); 264 - INIT_LIST_HEAD(&sbsec->list); 265 269 INIT_LIST_HEAD(&sbsec->isec_head); 266 270 spin_lock_init(&sbsec->isec_lock); 267 271 sbsec->sb = sb; ··· 275 281 static void superblock_free_security(struct super_block *sb) 276 282 { 277 283 struct superblock_security_struct *sbsec = sb->s_security; 278 - 279 - spin_lock(&sb_security_lock); 280 - if (!list_empty(&sbsec->list)) 281 - list_del_init(&sbsec->list); 282 - spin_unlock(&sb_security_lock); 283 - 284 284 sb->s_security = NULL; 285 285 kfree(sbsec); 286 286 } ··· 600 612 /* Defer initialization until selinux_complete_init, 601 613 after the initial policy is loaded and the security 602 614 server is ready to handle calls. */ 603 - spin_lock(&sb_security_lock); 604 - if (list_empty(&sbsec->list)) 605 - list_add(&sbsec->list, &superblock_security_head); 606 - spin_unlock(&sb_security_lock); 607 615 goto out; 608 616 } 609 617 rc = -EINVAL; ··· 790 806 791 807 /* 792 808 * if the parent was able to be mounted it clearly had no special lsm 793 - * mount options. thus we can safely put this sb on the list and deal 794 - * with it later 809 + * mount options. thus we can safely deal with this superblock later 795 810 */ 796 - if (!ss_initialized) { 797 - spin_lock(&sb_security_lock); 798 - if (list_empty(&newsbsec->list)) 799 - list_add(&newsbsec->list, &superblock_security_head); 800 - spin_unlock(&sb_security_lock); 811 + if (!ss_initialized) 801 812 return; 802 - } 803 813 804 814 /* how can we clone if the old one wasn't set up?? */ 805 815 BUG_ON(!(oldsbsec->flags & SE_SBINITIALIZED)); ··· 5658 5680 return 0; 5659 5681 } 5660 5682 5683 + static void delayed_superblock_init(struct super_block *sb, void *unused) 5684 + { 5685 + superblock_doinit(sb, NULL); 5686 + } 5687 + 5661 5688 void selinux_complete_init(void) 5662 5689 { 5663 5690 printk(KERN_DEBUG "SELinux: Completing initialization.\n"); 5664 5691 5665 5692 /* Set up any superblocks initialized prior to the policy load. */ 5666 5693 printk(KERN_DEBUG "SELinux: Setting up existing superblocks.\n"); 5667 - spin_lock(&sb_lock); 5668 - spin_lock(&sb_security_lock); 5669 - next_sb: 5670 - if (!list_empty(&superblock_security_head)) { 5671 - struct superblock_security_struct *sbsec = 5672 - list_entry(superblock_security_head.next, 5673 - struct superblock_security_struct, 5674 - list); 5675 - struct super_block *sb = sbsec->sb; 5676 - sb->s_count++; 5677 - spin_unlock(&sb_security_lock); 5678 - spin_unlock(&sb_lock); 5679 - down_read(&sb->s_umount); 5680 - if (sb->s_root) 5681 - superblock_doinit(sb, NULL); 5682 - drop_super(sb); 5683 - spin_lock(&sb_lock); 5684 - spin_lock(&sb_security_lock); 5685 - list_del_init(&sbsec->list); 5686 - goto next_sb; 5687 - } 5688 - spin_unlock(&sb_security_lock); 5689 - spin_unlock(&sb_lock); 5694 + iterate_supers(delayed_superblock_init, NULL); 5690 5695 } 5691 5696 5692 5697 /* SELinux requires early initialization in order to label
-1
security/selinux/include/objsec.h
··· 55 55 56 56 struct superblock_security_struct { 57 57 struct super_block *sb; /* back pointer to sb object */ 58 - struct list_head list; /* list of superblock_security_struct */ 59 58 u32 sid; /* SID of file system superblock */ 60 59 u32 def_sid; /* default SID for labeling */ 61 60 u32 mntpoint_sid; /* SECURITY_FS_USE_MNTPOINT context for files */