Christoph Hellwig <hch@xxxxxxxxxxxxx> writes: >> + else { >> + spin_lock(&filp->f_lock); >> + filp->f_flags = (arg & SETFL_MASK) | >> + (filp->f_flags & ~SETFL_MASK); >> + spin_unlock(&filp->f_lock); > > Please move this into an exported generic_file_set_flags helper, that > the filesystems can use in their implementations instead of duplicating > it. Ok. Will do > > Also a more conceptual question: Basically any check the filesystems > may perform needs to be duplicated in open and ->set_flags. Any chance > to have the open path call into ->set_flags? After your point I've checked various ->open callbacks and found that most filesystem makes important decisions such as: cifs_open: if (file->f_flags & O_DIRECT && cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) file->f_op = &cifs_file_direct_nobrl_ops; else file->f_op = &cifs_file_direct_ops; } } And I am completely agree that it is reasonable to move such functionality to ->set_flags and let ->open call ->set_flags internally. ->set_flags can determine that it is called from open by condition: (filp->f_flags & SETFL_MASK) == (arg & SETFL_MASK) I'll fix setfl to prevent ->set_flags if args are the same
Attachment:
pgpUd7taQ7iug.pgp
Description: PGP signature